@ AuthorYHCdatagrid you can change its view to display different effects. using the Details View, the datagrid can display the expand button (& quot; + & quot; or & quot;-& quot;) on the left of the Data row, you can expand a row to display additional details. view Demo Step 1: create... S
@ Author YHC
The datagrid can change its view to display different effects. using the Details View, the datagrid can display the expand button ("+" or "-") on the left of the Data row. You can expand a row to display an additional details.
View Demo
Step 1: Create a DataGrid
[Html]
Item ID |
Product ID |
List Price |
Unit Cost |
Status |
Item ID |
Product ID |
List Price |
Unit Cost |
Status |
Step 2: Set a detailed view for the DataGrid
When using the detailed view, remember to introduce the header of the View script file on your page.
[Html]
[Javascript] view plaincopyprint? $ ('# Dg'). datagrid ({
View: detailview,
DetailFormatter: function (index, row ){
Return '';
},
OnExpandRow: function (index, row ){
$ ('# Ddv-' + index). panel ({
Border: false,
Cache: false,
Href: 'maid _ getdetail. php? Itemid = '+ row. itemid,
OnLoad: function (){
$ ('# Dg'). datagrid ('fixdetailrowheight', index );
}
});
$ ('# Dg'). datagrid ('fixdetailrowheight', index );
}
});
$ ('# Dg'). datagrid ({
View: detailview,
DetailFormatter: function (index, row ){
Return '';
},
OnExpandRow: function (index, row ){
$ ('# Ddv-' + index). panel ({
Border: false,
Cache: false,
Href: 'maid _ getdetail. php? Itemid = '+ row. itemid,
OnLoad: function (){
$ ('# Dg'). datagrid ('fixdetailrowheight', index );
}
});
$ ('# Dg'). datagrid ('fixdetailrowheight', index );
}
}); We define the detailFormatter function to tell the datagrid how to render the detailed view. In this case, we return a simple ''element that acts as the most detailed container,
Note: The details are empty. When you click the expand button ('+'), The onExpandRow event will be triggered, so we can write some code to load the ajax details, finally, we call the fixDetailRowHeight method to fix the Row Height. After the detailed content is loaded.
Step 3: server code
Datagrid21_getdetail.php
[Php]
$ Itemid = $ _ REQUEST ['itemid'];
$ Content = file_get_contents ('data/datagrid_data.json ');
$ Data = json_decode ($ content, true );
Foreach ($ data ['rows '] as $ item ){
If ($ item ['itemid'] = $ itemid ){
Break;
}
}
?>
Echo ""; ?>
|
Item ID: |
|
Product ID: |
|
List Price: |
|
Unit Cost: |
|
Attribute: |
|
Author: yhc13429826359