Results 1 to 7 of 7

Thread: Combo Box Hidden Value

  1. #1
    Sencha User
    Join Date
    May 2009
    Posts
    42
    Answers
    6

    Default Answered: Combo Box Hidden Value

    I am attempt to use CellEditor to allow user to modify values inside a table. This is all working fine except that after the selection is made it displays the value instead of the display value inside the table. I attempted to add a hidden name as 'userGroupId' and have it populate that with the value instead using the hidden name property, but this didn't seem to work. I next attempted to catch the edit using the following code inside my ViewController, but I am getting a Uncaught TypeError: Cannot read property 'setValue' of undefined error, I do believe if I was able to use the setValue of userGroupId would resolve my issue thanks for you input!:
    Code:
       onCellEditingValidateedit: function(editor, context, eOpts) {
            console.log(context.value);
            var UserGroupComboValue = Ext.ComponentQuery.query('#UserGroupCombo')[0].getRawValue();
            console.log(UserGroupComboValue);
            Ext.ComponentQuery.query('#userGroupId')[0].setValue(UserGroupComboValue);
        }

  2. My issue wasn't how to implemented Dropdown into a datagrid, that was pretty easy. My issues was the the id of the selected drop down was shown instead of the display value. I was able to get around this by creating a hidden field in the data grid and then placing the id there and copying the display value into another column inside the datagrid using the following on a ViewController Edit event:
    Code:
    console.log(context.value);
    var UserGroupId = context.value;
    var UserGroupComboValue = Ext.ComponentQuery.query('#UserGroupCombo')[0].getRawValue();
    console.log(UserGroupComboValue);
    var grid = Ext.ComponentQuery.query('#PedningGridPanel')[0];
    var sel_model = grid.getSelectionModel();
    var record = sel_model.getSelection()[0];
    record.set("userGroupId", UserGroupId);
    record.set("userGroupDisplay", UserGroupComboValue);

  3. #2
    Sencha - Community Support Team jsakalos's Avatar
    Join Date
    Apr 2007
    Location
    Slovakia
    Posts
    27,664
    Answers
    512
    Jozef Sakalos, aka Saki

    Education, extensions and services for developers at new http://extjs.eu
    News: Grid MultiSearch Plugin, Grid MultiSort Plugin, Configuring ViewModel Hierarchy


  4. #3
    Sencha User
    Join Date
    May 2009
    Posts
    42
    Answers
    6

    Default

    My issue wasn't how to implemented Dropdown into a datagrid, that was pretty easy. My issues was the the id of the selected drop down was shown instead of the display value. I was able to get around this by creating a hidden field in the data grid and then placing the id there and copying the display value into another column inside the datagrid using the following on a ViewController Edit event:
    Code:
    console.log(context.value);
    var UserGroupId = context.value;
    var UserGroupComboValue = Ext.ComponentQuery.query('#UserGroupCombo')[0].getRawValue();
    console.log(UserGroupComboValue);
    var grid = Ext.ComponentQuery.query('#PedningGridPanel')[0];
    var sel_model = grid.getSelectionModel();
    var record = sel_model.getSelection()[0];
    record.set("userGroupId", UserGroupId);
    record.set("userGroupDisplay", UserGroupComboValue);

  5. #4
    Sencha Premium Member yorl1n's Avatar
    Join Date
    Mar 2015
    Location
    Germany
    Posts
    294
    Answers
    30

    Default

    You can achieve this by using renderer for your column:

    Code:
    {
    xtype: 'column',
    ...
    editor: {
        xtype: 'combo',
        ....
    },
    renderer: function () {
        return arguments[1].getEditor().getSelectedRecord().get('<name of name property>');
    }

  6. #5
    Sencha - Community Support Team jsakalos's Avatar
    Join Date
    Apr 2007
    Location
    Slovakia
    Posts
    27,664
    Answers
    512

    Default

    Well, the example I've posted the link to is all about showing text instead of id in the grid for foreign keys. That solution might not be suitable in your case but for me it works reliably in really large applications.
    Jozef Sakalos, aka Saki

    Education, extensions and services for developers at new http://extjs.eu
    News: Grid MultiSearch Plugin, Grid MultiSort Plugin, Configuring ViewModel Hierarchy


  7. #6
    Sencha User yeghikyan's Avatar
    Join Date
    Mar 2009
    Location
    München
    Posts
    574
    Answers
    99

    Default

    Once I worked with a programmer in team, who had the same coding style:
    Code:
    arguments[1].getEditor().getSelectedRecord().get('<name of name property>');
    and even longer and unreadabler. Am morgen you will ask yourself, WTF have I smoked yesterday.
    "The competent programmer is fully aware of the strictly limited size of his own skull; therefore he approaches the programming task in full humility, and among other things he avoids clever tricks like the plague." – Edsger W. Dijkstra

  8. #7
    Sencha Premium Member yorl1n's Avatar
    Join Date
    Mar 2015
    Location
    Germany
    Posts
    294
    Answers
    30

    Default

    yeghikyan,

    It was just a quick answer.

Similar Threads

  1. Setting a combo value and hidden value
    By PCSpectra in forum Ext 3.x: Help & Discussion
    Replies: 6
    Last Post: 8 Nov 2010, 6:12 PM
  2. Replies: 3
    Last Post: 16 Feb 2009, 4:44 AM
  3. Combo BeforeQuery and hidden list
    By randomuser01 in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 28 Nov 2008, 5:36 AM
  4. hidden combo values?
    By trickytoad in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 3 Mar 2008, 8:27 AM
  5. Combo Box hidden value ?
    By quartex in forum Ext 1.x: Help & Discussion
    Replies: 7
    Last Post: 29 Oct 2007, 5:15 PM

Tags for this Thread

Posting Permissions

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