In an editable form EditorGrid, I chose a line of data has been entered, click the Delete button, the row data will be deleted, and then when I click on the submit form button, the row data has been deleted is still inserted into the database ...

 

Problem Description: In an editable table, I chose the data line has been entered, click the Delete button, the row data will be deleted, and then when I click on a form submit button, the row data has been deleted is still inserted into the database.

 

1: I can edit the table:

  

2: When you select a row, click the Delete button in a row:

  

3: After successfully deleted:

  

It is that when I click on the "submit" button, still will insert two records in the database (including the row data I deleted).

I deleted a line of code:

/*
 *  1:grid是当前的可编辑表格 我的是:var grid  =   newExt.grid.EditorGridPanel({});
 * 2: store是可编辑表格中定义的数据源,我的是:var store = newExt.data.JsonStore({});
 */
       var sm = grid.getSelectionModel();
       var cell =sm.getSelectedCell();
      
       var record =store.getAt(cell[0]);
       store.remove(record);

 

Workaround: Add property configuration options in your store:

  pruneModifiedRecords: true

  API Explanation: This is true in the store will be loaded or when a record is deleted, cleared modify the information of all records (the default is false to say when I click delete a row operation, in fact, the line that the data will be deleted. there, but do not show nothing, if you configure the option is true, when we delete a line operation, putting the line that you want to delete the data to clear out.


as follows:

var store = new Ext.data.JsonStore({
       data : data,
       pruneModifiedRecords : true,
       fields : ['detailCosts','detailType','detailPaid','detailDescription',{name : 'detailTime',type : 'date', dateFormat : 'Y-m-d'}]
    });

Submit those data delete operation after a row add, and then click the submit button will not delete the original has to back up!

 supplement:

  New line:

Var countnum=10;//你的可编辑表格的初始最大行数
 var p = new Record({
           detailCosts : '',
           detailType  : '',
           detailPaid  : '2',
           detailTime  : '',
           detailDescription : ''
       });
       grid.stopEditing();
       store.insert(countnum,p);
       countnum++;

 Move up:

var sm =grid.getSelectionModel();
       var cell = sm.getSelectedCell();
       var record = store.getAt(cell[0]);
       var index = cell[0];
       if(index > 0){
           store.remove(record);
           store.insert(index-1,record)
           grid.getView().refresh();
       }

 Down:

var sm =grid.getSelectionModel();
       var cell = sm.getSelectedCell();
       var record = store.getAt(cell[0]);
       var index = cell[0];
      
       if(index < store.getCount()-1){
           store.remove(record);
           store.insert(index+1,record)
           grid.getView().refresh();
       }

Reproduced in: https: //my.oschina.net/mapsh/blog/598139

Guess you like

Origin blog.csdn.net/weixin_33757609/article/details/91691130