Dynamic Div Creation?
-
Hello, I need some advices please. I'm trying to build a website for real estate listing. now the data would look like a datagrid. and while clicking on a row, it should open under it the dynamic data related to the specific row. (like an AJAX accordion). I will try to explain myself in a better way. this website for example ( ignore the language, couldnt find any better example LOL) http://www.yad2.co.il/Nadlan/rent.php Now, i've been told that this works by using "Dynamic Div Creation" which i have no idea how it should work this way. Is it possible to make it work by using an Accordion inside a datagrid? or what?!! If anybody can advice me or give me a sample code of doing such a thing i would be REALLY grateful.
-
Hello, I need some advices please. I'm trying to build a website for real estate listing. now the data would look like a datagrid. and while clicking on a row, it should open under it the dynamic data related to the specific row. (like an AJAX accordion). I will try to explain myself in a better way. this website for example ( ignore the language, couldnt find any better example LOL) http://www.yad2.co.il/Nadlan/rent.php Now, i've been told that this works by using "Dynamic Div Creation" which i have no idea how it should work this way. Is it possible to make it work by using an Accordion inside a datagrid? or what?!! If anybody can advice me or give me a sample code of doing such a thing i would be REALLY grateful.
The accordion control is just a container, a div, for your controls so yes you can have anything you'd like there. Handle the client side click of the datagrid and make an ajax query for the data, populate the controls as necessary and expand the accordion.
I know the language. I've read a book. - _Madmatt
-
The accordion control is just a container, a div, for your controls so yes you can have anything you'd like there. Handle the client side click of the datagrid and make an ajax query for the data, populate the controls as necessary and expand the accordion.
I know the language. I've read a book. - _Madmatt
Hi Mark, i've reached this point, which is close but not what i want The JS code is :
function toggleDivVisibility(id) { var divcontrol = document.getElementById(id); if (divcontrol.style.display == 'block') divcontrol.style.display = 'none'; else divcontrol.style.display = 'block'; }
And Inside the ItemTemplate of the GridView, there is this code:
< ItemTemplate >
< a onclick = 'return void(0);' href="<%# DataBinder.Eval(Container,"RowIndex","javascript:toggleDivVisibility('Div{0}')") %>">More..
// The code i wanted to show inside the div//
< /div >This really does open a Div but the problem is that it opens it under the ItemTemplate(column) and not under the ROW. any ideas? Thanks
-
Hi Mark, i've reached this point, which is close but not what i want The JS code is :
function toggleDivVisibility(id) { var divcontrol = document.getElementById(id); if (divcontrol.style.display == 'block') divcontrol.style.display = 'none'; else divcontrol.style.display = 'block'; }
And Inside the ItemTemplate of the GridView, there is this code:
< ItemTemplate >
< a onclick = 'return void(0);' href="<%# DataBinder.Eval(Container,"RowIndex","javascript:toggleDivVisibility('Div{0}')") %>">More..
// The code i wanted to show inside the div//
< /div >This really does open a Div but the problem is that it opens it under the ItemTemplate(column) and not under the ROW. any ideas? Thanks
Of course it is in the cell, you're defining the template for it not the row. :rolleyes: What you need are controls like these http://samples.infragistics.com/2010.2/WebFeatureBrowser/Default.aspx[^] http://demos.telerik.com/aspnet-ajax/grid/examples/hierarchy/nestedviewtemplate/defaultcs.aspx[^] or build your own, which looking at the source for these samples should give you the idea. In this case a DataListView or Repeater may server your needs better than a DataGridView. Just because something is displayed in a grid doesn't mean you need to use a grid control.
I know the language. I've read a book. - _Madmatt
-
Of course it is in the cell, you're defining the template for it not the row. :rolleyes: What you need are controls like these http://samples.infragistics.com/2010.2/WebFeatureBrowser/Default.aspx[^] http://demos.telerik.com/aspnet-ajax/grid/examples/hierarchy/nestedviewtemplate/defaultcs.aspx[^] or build your own, which looking at the source for these samples should give you the idea. In this case a DataListView or Repeater may server your needs better than a DataGridView. Just because something is displayed in a grid doesn't mean you need to use a grid control.
I know the language. I've read a book. - _Madmatt