EasyUI implements the method of selecting the content of the second-level page, and easyui implements the second-level page

Source: Internet
Author: User

EasyUI implements the method of selecting the content of the second-level page, and easyui implements the second-level page

EasyUI, when adding or deleting files, the secondary page is often checked.

You can add onCheck, onUncheck, onSelectAll, and onUnselectAll events under IRD.

In these events, save the selected content to map and convert it to a json string to put it in the hidden domain.

Copy codeThe Code is as follows:
OnCheck: function (rowIndex, rowData)
If (rowIndex>-1 ){
Var userId = rowData. id;
If (! DataMap. containsKey (userId ))
{
DataMap. put (userId, rowData );
$ ("Input [name = selectData]"). val (JSON. stringify (dataMap ));
}
}
},
OnUncheck: function (rowIndex, rowData ){
If (rowIndex>-1 ){
Var userId = rowData. id;
If (dataMap. containsKey (userId ))
{
DataMap. remove (userId );
$ ("Input [name = selectData]"). val (JSON. stringify (dataMap ));
}
}
},
OnSelectAll: function (rows ){
For (var I = 0; I <rows. length; I ++ ){
Var rowData = rows [I];
Var userId = rowData. id;
If (! DataMap. containsKey (userId ))
{
DataMap. put (userId, rowData );
$ ("Input [name = selectData]"). val (JSON. stringify (dataMap ));
}
}
},
OnUnselectAll: function (rows ){
For (var I = 0; I <rows. length; I ++ ){
Var rowData = rows [I];
Var userId = rowData. id;
If (dataMap. containsKey (userId ))
{
DataMap. remove (userId );
$ ("Input [name = selectData]"). val (JSON. stringify (dataMap ));
}
}
}

On the parent page, obtain the content in the hidden domain.

SelectForm is the id of the form on the second-level page, and selectData is the hidden field that stores the selected data in the form.

Convert the data in the hidden domain to json format, and extract the data one by one in the form of map.

The userId and rowData are map. elements [I]. key and map. elements [I]. value respectively.

Copy codeThe Code is as follows:
Var f = parent. $. modalDialogTwo. handler. find ('# selectForm ');
Var selectData = f. find ('input [name = "selectData"] '). get (0). value;
If (! SelectData ){
Parent. $. messager. alert ('hprompt ', "select a record! ");
Return;
}
Var map = jQuery. parseJSON (selectData );
If (map. elements. length> 0 ){
Var nos = new Array ();
Var names = new Array ();
For (var I = 0; I <map. elements. length; I ++ ){
Var data = map. elements [I];
Nos. push (data. key );
Names. push (data. value. name );
}

The above is the method for selecting the content of the EasyUI implementation level 2 page, which I hope will be helpful to you.

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.