Home  >  Article  >  Web Front-end  >  EasyUI method to implement content selection on secondary pages_jquery

EasyUI method to implement content selection on secondary pages_jquery

WBOY
WBOYOriginal
2016-05-16 16:11:501189browse

EasyUI, when adding or deleting, often use the secondary page to check.

You can add onCheck, onUncheck, onSelectAll, onUnselectAll events under datagird.

In these events, the checked content is stored in the map, converted into a json format string and placed in the hidden field.

Copy code 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, get the content in the hidden field.

selectForm is the id of the form on the secondary page, and selectData is the hidden field in the form that stores the check data.

Convert the data in the hidden field into json format, and then use map to extract the data one by one.

Finally userId and rowData are map.elements[i].key and map.elements[i].value respectively.

var f = parent.$.modalDialogTwo.handler.find('#selectForm');
var selectData = f.find('input[name="selectData"]').get(0).value;
If (!selectData) {
parent.$.messager.alert('prompt', "Please 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 EasyUI method to share with you how to check the content of the secondary page. I hope it can be helpful to everyone.
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn