简体   繁体   中英

Extjs 4.2: How to set the value of grid

I have a grid for terminals, What I want to do now is to display the selected terminals into another grid. I am able to get the selected terminals with this code:

var sel = scope.getTerminalGrid().getSelectionModel().getSelection();
var user = scope.getProfinfo().getForm().getValues();

for(var i=0; i < sel.length; i++)
{
var terminals = sel[i].data;
}

You can simply get the data (in your case above its the 'sel' variable) and then load it in the second grid store.

Something like that:

var sel = scope.getTerminalGrid().getSelectionModel().getSelection();
var selRecords = sel.getSelection();
var secondGrid = scope.getMySecondGrid();
var secondStore = secondGrid.getStore();

secondGrid.removeAll(); //Clear the data
secondGrid.add(selRecords);

Of course, I separated all in a lot of variables, you can abstract some of them.

you can do it multiple ways, one is with a drag and drop grid group, another is grabbing the grid of second store like so .

   var secondGrid = scope.getMySecondGrid()
   secondGrid.getStore()

the store is the powerful underlying data structure of the grid. You can then load any data you want in there.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM