[CLOSED] Add new row to grid (dirty is false)

  1. #1

    [CLOSED] Add new row to grid (dirty is false)

    I have a complex grid. I want to add a new row but I want the row to be "not-dirty" and the state of the grid not dirty.

    Therefore if I click grid.save(), it should be a no-op.

    I poked through the forums but didn't see what I needed. The code below is what I use to add a new row AND mark the row and any changed cell as dirty

    Thanks,
    /Z

            var generateNewRow = function (command, rowData, grid, record) {
                rowInsertCounter -= 1;
                var rowIndex = index = grid.store.indexOf(record);
                var newRecord = {
                    id: a, b: rowData.b, c: rowData.c
                };
                //persisted and dirty!
                var totalCount = grid.store.getCount() + grid.store.modified.length;
                if (rowIndex == totalCount - 1) {
                    grid.addRecord(newRecord);
                } else {
                    grid.insertRecord(rowIndex + 1, newRecord);
                }
                var recordAdded = grid.store.getById(rowInsertCounter);
                recordAdded.phantom = true;
                grid.render();
                return rowIndex;
            };
    Last edited by Daniil; Nov 07, 2014 at 4:01 AM. Reason: [CLOSED]
  2. #2
    Hi @Z,

    I want to add a new row but I want the row to be "not-dirty" and the state of the grid not dirty.
    I would try this.
    record.commit();
    record.phantom = false;
  3. #3
    That worked. Would the same hold true if I deleted a row from a grid. On the deletion case... I would want to delete it and have store.modified=[] as if I didn't happen.reason is this is handed in realtime and not on save()
  4. #4
    As far as I can know deleted records don't go to a Store's modified, they go to a Store's deleted array.

    I would say you can do the following.
    store.removeAt(0);
    store.deleted = [];
  5. #5
    thanks. it worked well
    /Z

Similar Threads

  1. [CLOSED] enable dirty flag for new row added to grid
    By susanz in forum 2.x Legacy Premium Help
    Replies: 4
    Last Post: Sep 07, 2014, 2:13 AM
  2. [CLOSED] is my grid dirty?
    By Z in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Jul 20, 2014, 6:37 PM
  3. Remove red dirty flags from grid.
    By AaronB3 in forum 1.x Help
    Replies: 2
    Last Post: Jun 27, 2011, 9:47 PM
  4. How to set Grid record dirty?
    By speddi in forum 1.x Help
    Replies: 0
    Last Post: Jul 16, 2010, 8:47 PM
  5. Marking all records as dirty in a grid
    By n_s_adhikari@rediffmail.com in forum 1.x Help
    Replies: 1
    Last Post: May 10, 2010, 11:35 PM

Posting Permissions