Results 1 to 4 of 4

Thread: Change grid header and store dataindex

  1. #1
    Sencha User JNason's Avatar
    Join Date
    Aug 2007
    Location
    Louisville
    Posts
    43

    Default Change grid header and store dataindex

    I've been searching through the forums, but haven't found an answer to my question. Here is what I'm trying to do.

    I have the user upload their CSV file. They are then taken to a screen that has their file information presented in a extjs dynamic xml grid. The headers have the same name as the header row in their file or the words "column0, column1,etc" if they have no header row. What I'm trying to do is allow them to match their columns to ours by picking from the table column names on our system. I created a custom menu on the column headers that right now just goes to an alert message saying which column they picked.

    What I want to do is once they click on the new header menu item, it takes them to a message window where they will select the right column name. When they select that name, I need to change the header on the grid and the corresponding part of the store. This way, they see the changes and when I save the store, the changes go with it. Is this possible with extjs or am I trying to do something that isn't doable?

    Thanks for any help in advance.

  2. #2
    Sencha User JNason's Avatar
    Join Date
    Aug 2007
    Location
    Louisville
    Posts
    43

    Default

    I am able to change the visual name of the column by using setColumnHeader.

    Code:
    var cm = Ext.getCmp('reportViewGrid').getColumnModel();
    cm.setColumnHeader(colIndex,'TEST');
    When I commit the grid I'm using the following code:

    Code:
    function commit() {
        var grid = Ext.ComponentMgr.get('reportGrid');
        var ds=grid.store;
        gridindex=ds.data.length;
        jsonData = "[";
        ds.each(function(ds){
            jsonData += Ext.util.JSON.encode(ds.data) + ",";
        });
        jsonData = jsonData.substring(0,jsonData.length-1) + "]";
    }
    The json data that I'm getting back is still using the original name for the columns. I'm sure I'm missing something, but I at this point I don't know what it is yet. Any help would be appreciated.

  3. #3
    Sencha User JNason's Avatar
    Join Date
    Aug 2007
    Location
    Louisville
    Posts
    43

    Default

    It's been a while since I was working on this, but figured I should come back and post what I ended up with. Essentially, I wasn 't able to figure out how to actually change the name of the field in the store, so I just send a second list of the old & new names when the grid is saved. Not exactly what I initially envisioned, but it works.

  4. #4

    Default

    You might consider gridPanel's reconfigure() method, or using a user extension that looks for store/cm metadata in the payload data (remoteComponent I think does this).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •