EasyUI, when adding or deleting, it often uses the secondary page to check it.
You can add onCheck, onUncheck, onSelectAll, and onUnselectAll events under datagird.
In these events, the checked content is saved in the map and converted into a json format string and placed in the hidden domain.
The code copy 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, get the content in the hidden domain.
selectForm is the id of the form form of the secondary page, and selectData is the hidden field in the form form that stores the selected data.
Convert the data in the hidden domain into json format, and then extract the data one by one in the form of map.
Finally, userId and rowData are map.elements[i].key and map.elements[i].value, respectively.
The code copy 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('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 method of EasyUI to check content on the secondary page that I shared with you. I hope it will be helpful to you.