从网格的行创建列表的最佳方法是什么? [英] What is the best way to create a list from the rows of a grid

查看:266
本文介绍了从网格的行创建列表的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中有两个拖放网格。

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.

这篇关于从网格的行创建列表的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆