从网格的行创建列表的最佳方法是什么?
在我的应用程序中有两个拖放网格。
In my app there are two drag and drop grid.
要创建列表,请将行从第一个网格拖动到第二个网格。
To create a list, you drag rows from the first to the second grid.
发送这个服务器列表(第二个网格),然后在另一个网格中显示的最佳方式是什么?
What is the best way to send this list of rows (second grid) for the server to then be displayed in another grid?
我尝试同步并设置Dirty(true),但是不推荐使用Ext.data.Model#setDirty。
I tried to sync and setDirty (true), but "Ext.data.Model # setDirty" is deprecated.
var grid = this.lookupReference('gridRef');
var store = grid.getStore();
store.each(function(record){
record.setDirty(true);
});
store.sync();
我尝试,失败:
var grid = this.lookupReference('gridRef');
var store = grid.getStore();
grid.getSelectionModel().selectAll();
var selection = grid.getSelectionModel().getSelection();
var values = [];
for(var i=0; i<selection.length; i++) {
values.push(selection[i].get('order'));
values.push(selection[i].get('item'));
}
var model = Ext.create('app.myModel', values);
console.log(model) //show just one item
????
EDITED:
var grid = this.lookupReference('gridRef');
var store = grid.getStore();
var records = store.getRange();
var create = 'create'; //PHP CRUD » case create
Ext.Ajax.request({
url: 'php/crudActionList.php?create',
method: 'POST',
params : create,
jsonData: records,
// jsonData: Ext.encode(records),
// jsonData: Ext.JSON.encode(records),
success: function(conn, response, options, eOpts) {
console.log('Success!');
},
failure: function(conn, response, options, eOpts) {
console.log('failure')
}
});
将整个范围的记录从商店发送到服务器在单个 Ext.Ajax.request
中,您可以尝试:
To send the whole range of records from the store to the server in a single Ext.Ajax.request
, you could try:
Ext.Ajax.request({
url:'testURL',
jsonData:store.getRange()
});
或者您可以在记录中有一个特殊字段,其中包含记录是否在名单。将非持久性布尔字段设置为defaultValue false
,并将 onDrop
设置为true。而且voilá,记录应该是脏的。
Or you can have a special field in your record, that contains whether or not the record is in the list. Set the non-persistent boolean field to defaultValue false
, and onDrop
set it to true. And voilá, the record should be dirty.