fiqs8sjn5by0n

EditorGridPanel: Current value of cell

By mike | January 6, 2009

  • I have an EditorGridPanel which is auto-refreshing every 5 seconds. This grid has 4 editable columns. In order to ensure edit completeness, in case the refresh happens while the user is typing, I need to read the current value and after store.load(), set it back in the cell.

    Using the beforeEdit event, I can get to the row/field that was being edited. However, I'm unable to get to the current value in the cell. Store.getModifiedRecords() only works once the user tabs out of the field (in which case I can also get it via afteredit).

    How can I read the current dirty value in a cell using fieldName/colIndex & row?

    Thanks


  • Let's say I intend to enter 500 in a field called 'Size' and I manage to type in '50' before the store refresh occured. In order to force the 50 back into the cell, I want to save it in from store.onLoad.

    grid.preEditValue sounds like it could be what I'm looking for but using your code, it doesn't return anything while I'm sitting in the cell after having typed 50. I do get the correct field from grid.activeEditor.col.

    Hopefully, this clarifies my use case better.

    Thanks Condor


  • Sorry, PEBKAC. It's fixed now.


    var recId, field, value;
    ds.on({
    beforeload: function() {
    recId = null;
    field = null;
    value = null;
    if (grid.activeEditor) {
    recId = grid.activeEditor.record.data.Contract;
    field = grid.colModel.getDataIndex(grid.activeEditor.col);
    value = grid.activeEditor.getValue();
    }
    },
    load: function() {
    if (recId) {
    var row = ds.findBy(function(r,i){
    return recId == r.data.Contract;
    });
    var col = grid.colModel.findColumnIndex(field);
    grid.startEditing(row, col);
    (function() {
    grid.activeEditor.field.setValue(value);
    recId = null;
    field = null;
    value = null;
    }).defer(50, this);
    }
    }
    });


  • I'm getting an exception on store load, unfortunately. Any idea what's going on? I do see the caret blink in the cell after store load.

    Thanks


    grid.activeEditor is null
    load()()MarketAc...rsion=1.0 (line 101)
    fire()()ext-all-...rsion=1.0 (line 1488)
    fireEvent()()ext-all-...rsion=1.0 (line 1184)
    loadRecords()(Object success=true records=Object totalRecords=203, Object params=Object, true)ext-all-...rsion=1.0 (line 10858)
    loadResponse()(Object params=Object request=Object reader=Object, true, Object tId=9 status=200 statusText=OK)ext-all-...rsion=1.0 (line 11342)
    getViewWidth()(function(), Object events=Object conn=Object useAjax=true, Object 0=Object 1=true 2=Object, undefined)ext-base...rsion=1.0 (line 9)
    handleResponse()(Object tId=9 status=200 statusText=OK)ext-all-...rsion=1.0 (line 5318)
    getViewWidth()(Object conn=XMLHttpRequest tId=9, Object scope=Object argument=Object timeout=30000, undefined)ext-base...rsion=1.0 (line 10)
    getViewWidth()()ext-base...rsion=1.0 (line 10)

    grid.activeEditor.field.setValue(value);




    var recId, field, value;
    ds.on({
    beforeload: function() {
    recid = null;
    field = null;
    value = null;
    if (grid.activeEditor) {
    recId = grid.activeEditor.record.data.Contract;
    field = grid.colModel.getDataIndex(grid.activeEditor.col);
    value = grid.activeEditor.field.getValue();
    }
    },
    load: function() {
    if (recId) {
    var row = ds.findBy(function(r,i){
    return recId == r.data.Contract;
    });
    var col = grid.colModel.findColumnIndex(field);
    grid.startEditing(row, col);
    grid.activeEditor.field.setValue(value); // this is the error line
    }
    }
    });


  • I'm not completely sure what you are asking...

    Are you looking for:
    if (grid.activeEditor) {
    var id = activeEditor.record.id;
    var record = grid.store.getById(id);
    var field = grid.colModel.getDataIndex(activeEditor.col);
    var value = grid.preEditValue(record, field);
    activeEditor.field.setValue(value);
    }


  • I tried defering the setValue. Although the error went away, no text is showing up in the cell.

    Thanks


    (function() {
    grid.activeEditor.field.setValue(value);
    }).defer(50, this);


  • Looks like I just missed your post. But even better, thanks once again Condor!


  • Try:
    var recid, field, value;
    grid.store.on({
    beforeload: {
    if (grid.activeEditor) {
    recid = grid.activeEditor.record.id;
    field = grid.colModel.getDataIndex(activeEditor.col);
    value = grid.activeEditor.field.getValue();
    }
    },
    load: {
    if (recid) {
    var row = grid.store.indexOfId(recid);
    var col = grid.colModel.findColumnIndex(field);
    grid.startEditing(row, col);
    grid.activeEditor.field.setValue(value);
    }
    }
    });


  • Thanks for pointing me to activeEditor, Condor. It seems grid.activeEditor.getValue() returns the raw value currently entered in edit mode in a textbox.







  • #If you have any other info about this subject , Please add it free.#
    Your name:
    E-mail:
    Telphone:

    Your comments:


    If you have any other info about EditorGridPanel: Current value of cell , Please add it free.

    Topics: enart.xn--fiqs8sjn5by0n.com | edit

    Cash Loan: Affable Financial Assistance for Emergencies Learn Spoken English Through the Correct Method