1. #1
    Sencha User
    Join Date
    Oct 2012
    Posts
    1
    Vote Rating
    0
    Jeved is on a distinguished road

      0  

    Default Unanswered: Dynamic field handling in a Grid column.

    Unanswered: Dynamic field handling in a Grid column.


    I am somewhat new to ext js and have adopted a code base on a project I need to maintain going forward. The system uses Ext Js to make a editable spreadsheet of data records. I am currently trying to make an update which I have hit a dead end at. Lets take an example. I have a column for a status type. Options are New, In-progress, Complete. If the status on the record is not "Complete" when the user clicks on the cell it should give them a select list of the two options New or In-Progress. Certain other events that manipulate the data will change the record to status complete. When this occurs, if the cell is displaying the status 'complete' it will not be editable.

    My issue is I can only seem to do one or the other. I can make the column support the cells to be select lists or I can make the column un-editable. I cannot figure out how to handle each cell in its own way based on its value. Here is what the parts of the code would look like. (The actual code is jumbled into a lot of dynamically written files, and I unfortunately cant share those.)

    Field Definition...
    Code:
    var status_store = Ext.create('Ext.data.Store', {
        fields: ['text', 'value', 'ct'],
        data: [
                    { 'text': 'New', 'value': 'New' },
                    { 'text': 'In-Progress', 'value': 'In-Progress' }
            ]
    });
    
    var status_field = {
        xtype: 'combobox',
        selectOnTab: true,
        lazyRender: true,
        store: status_store,
        displayField: 'text',
        valueField: 'value',
        forceSelection: true
    };
    Column Definition...
    Code:
    var row_columns = [{
    text: 'Fields', locked: true, hideable: false, sortable: false, width: 400, columns: [{
    text: 'Status', hideable: false, width: 100, dataIndex: 'status', field: status_field, sortable: true
    }]
    }]
    I have found that using the code this way will use the select list for every cell in the column. If i remove the field property on the column definition it just renders the value statically. I want a way to detect if the value of the cell will be "Complete" and if it is remove the reference to the select list field definition.

    Is this possible? Or should I be attempting this in a completely different way.

    Thanks!

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,346
    Answers
    3541
    Vote Rating
    847
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Have you tried returning false in the beforeedit event on the grid panel? That should prevent editing
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

Thread Participants: 1

Tags for this Thread