Home > front end >  Js, two arrays to heavy
Js, two arrays to heavy

Time:12-13

As shown, select a user interface, in the parent interface display, but will add duplicate data, could you tell me how to heavy
 
//child pages this method is called by value (receive) user
The function dealData (userCode) {
Var data=https://bbs.csdn.net/topics/userCode;
Data=https://bbs.csdn.net/topics/eval (' (' + data + ') ');

All the data of Id//access to form and to array
Var ids=grid_1. GetAllRowIds (", ");
Var idsStr=ids. The split (", ");

//if the table data is empty, directly inserted into the
If (ids=="") {
For (var I=0; I & lt; Data. The length; I++) {
Var cols=new Array ();
Cols [1]=data [I] userCode;
Cols [2]=data [I] the userName.
Cols [3]=data [I] unitName;
Grid_1. AddRow (data [I] id, cols);
}
}
}

CodePudding user response:

All data is empty, if the form is directly inserted into the code to the
for(var i=0; iIds=grid_1. GetAllRowIds (", ");
IdsStr=ids. The split (", ");
Var independence idx=idsStr. FindIndex (e=& gt; E==data [I]. Id);
If (independence idx==1) {//whether the data in the chart, if not to insert the data
Var cols=new Array ();
Cols [0]=XXX;
.
Grid_1. AddRow (data [I] id, cols);
}
}

CodePudding user response:

You as shown in the diagram of

Application scenario is similar to: select some data, the selected item will be added to another container or for display in the window, however, is likely to choose to the same data?? It look like?