How to clear the DataGrid result set in EasyUI component under Jquery

Source: Internet
Author: User

We have a module, for example, to select "region" and "Maintenance Agency", refresh the first DataGrid frame.

Click the behavior data condition in the first result set to complete the search of the next frame.

 

Now we have completed the corresponding functions, and automatically refresh the first DataGrid (DG1) result set after selecting "region" and "Maintenance Agency" and ensuring that both options have values at the same time.

However, after the DG1 refresh is completed, the subsequent two DG2 and DG3 are followed by the previous results.

I tried to change the query conditions of DG2 and DG3 by manually passing an empty ID value to the query () method, but it was returned as the first query by the Controller layer in the background.

So we can find such a method and give them an empty result set string.

As follows:
Copy codeThe Code is as follows:
// Modify the selection box of Maintenance Agency and submit the query again
Function query1 (){
Var params = $ ('# dg1'). datagrid ('options'). queryParams;
Params. region = $ ('# region'). combotree ('getvalue ');
Params. company_id = $ ('# company_id'). combotree ('getvalue ');
Params. contract_type = "line"; // * Currently, lines are written dead, And tabs are optimized later.
If (params. company_id = "" | params. region = ""){
Return;
}
$ ("# Dg1"). datagrid ('load ');
$ ('# Dg2'). datagrid ('loaddata', {total: 0, rows: []}); // clear the DateGrid below
$ ('# Dg3'). datagrid ('loaddata', {total: 0, rows: []}); // clear the DateGrid below
}

In this way, the result set data in DG2 and DG3 can be cleared smoothly.

Another method is to traverse and delete the data in the result set.
Copy codeThe Code is as follows:
Var item = $ ('# filegrid'). datagrid ('getrows ');
If (item ){
For (var I = item. length-1; I> = 0; I --){
Var index = $ ('# filegrid'). datagrid ('getrowindex ', item [I]);
$ ('# Filegrid'). datagrid ('delterow ', index );
}
}

Same things

Related Article

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.