Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/444.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 只能编辑Dojo DataGrid的最后一行_Javascript_Datagrid_Dojo - Fatal编程技术网

Javascript 只能编辑Dojo DataGrid的最后一行

Javascript 只能编辑Dojo DataGrid的最后一行,javascript,datagrid,dojo,Javascript,Datagrid,Dojo,我使用的是dojo datagrid,它显示从服务器发送的坐标数据,或从添加到ESRI映射的管脚发送的坐标数据 但是,当我单击某个单元格以编辑文本框时,会显示文本框,您可以更改该值,但除非您正在编辑最后一行,否则更改不会保存。如果编辑第2行中的文本框,然后为最后一行单击同一列中的框,则第2行的值将放入最后一行 如果退出任何其他方式,第2行数据将恢复为其原始值。最后一行的行为完全符合我的要求,您可以编辑所有值并保存它们(除非刷新页面)。如果添加了另一行,并且您尝试对其进行编辑,则该行将抛出 Obj

我使用的是dojo datagrid,它显示从服务器发送的坐标数据,或从添加到ESRI映射的管脚发送的坐标数据

但是,当我单击某个单元格以编辑文本框时,会显示文本框,您可以更改该值,但除非您正在编辑最后一行,否则更改不会保存。如果编辑第2行中的文本框,然后为最后一行单击同一列中的框,则第2行的值将放入最后一行

如果退出任何其他方式,第2行数据将恢复为其原始值。最后一行的行为完全符合我的要求,您可以编辑所有值并保存它们(除非刷新页面)。如果添加了另一行,并且您尝试对其进行编辑,则该行将抛出

ObjectStore.js:8上的“未捕获的TypeError:无法读取未定义的”属性“get”错误

我从hellodgrid示例中的代码开始 使用“使用网格编辑数据”和任何行中已编辑的列

我还没有看到像我这样的问题,我真的很难堪,所以任何帮助都是非常感谢的

下面代码中的数据是我创建的对象数组

    function drawTable(data){
        require([
            "dojox/grid/DataGrid",
            "dojox/grid/cells",
            "dojox/grid/cells/dijit",
            "dojo/store/Memory",
            "dojo/data/ObjectStore",
            "dojo/date/locale",
            "dojo/currency",
            "dijit/form/DateTextBox",
            "dojox/grid/_CheckBoxSelector",
            "dojo/domReady!"
        ], function(DataGrid, cells, cellsDijit, Memory, ObjectStore, locale, currency,
            DateTextBox, _CheckBoxSelector){
            function formatDate(inDatum){
                return locale.format(new Date(inDatum), this.constraint);
            }
            gridLayout = [
              {
      type: "dojox.grid._CheckBoxSelector",
      defaultCell: { width: 8, editable: true, type: cells._Widget, styles: 'text-align: right;' }
              }, 
              //cells:
                    [

        { name: 'Number', field: 'order', editable: false /* Can't edit ID's of dojo/data items */ },
                    { name: 'ID', field: 'uniqueID', width: 10, editable: false /* Can't edit ID's of dojo/data items */ },
                    { name: 'Station ID', field: 'stationID', width: 15, editable: true },
                    /* No description for each station... at least not yet
        { name: 'Description', styles: 'text-align: center;', field: 'description', width: 10,
                        type: cells.ComboBox, 
                        options: ["normal","note","important"]},*/
                  { name: 'Road', field: 'road', width: 10, editable: true, styles: 'text-align: center;',
                        type: cells.CheckBox},  
                    { name: 'Route', field: 'route', width: 10, editable: true, styles: 'text-align: center;',
                        type: cells.CheckBox},
                    { name: 'Count Type', width: 13, editable: true, field: 'countType',
                        styles: 'text-align: center;',
                        type: cells.Select,
                        options: ["new", "read", "replied"] },
                    { name: 'Count Duration', field: 'countDuration', styles: '', width: 15, editable: true},
                    /*  
                  May want to use this later                    
                { name: 'Date', field: 'col8', width: 10, editable: true,
                        widgetClass: DateTextBox,
                        formatter: formatDate,
                        constraint: {formatLength: 'long', selector: "date"}}, */

                ]
              //{
            ];


            objectStore = new Memory({data:data});

            stationGridStore = new ObjectStore({objectStore: objectStore});

            //  create the grid.
            grid = new DataGrid({
                store: stationGridStore,
            structure: gridLayout,
    //          rowSelector: '20px',
                "class": "grid"
            }, "grid");
            grid.startup();

//          grid.canSort=function(){return false;};
        });
    }

您没有在问题中包含实际数据,但根据您的一列,我猜您的数据项在名为
uniqueID
的属性中存储了唯一标识符。但是,默认情况下,
dojo/store/Memory
假定唯一id位于
id
属性中。这种不匹配很可能是导致您出现问题的原因

通过在实例上设置
idProperty
,可以通知
dojo/store/Memory
您的唯一标识符位于另一个属性下:

objectStore = new Memory({ data: data, idProperty: 'uniqueID' });

哇,太谢谢你了!我不知道它假设了id属性。如果每一次修复都那么容易。。。