When EasyUI is used, we often check the secondary page. Here we will share with you a simple and practical implementation method. I hope you will like it. 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.
The 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 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 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.
The 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.