EasyUI expand the row in the DataGrid to display detailed information

Source: Internet
Author: User
@ 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 IDProduct IDList PriceUnit CostStatus
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
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.