jQWidgets Forums

jQuery UI Widgets Forums Grid Custom dropdown List column – display value instead of id

This topic contains 6 replies, has 2 voices, and was last updated by  assaf.frank123 11 years, 5 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author

  • assaf.frank123
    Participant

    Hi,

    I wish to implement in the grid that one of the columns is a dropdownList populated by different sources according to
    some attribute of the row.

    I followed customrowcelledit.htm and got it working fine –
    Each row populates the dropdown of of the cell properly.
    The problem that I can’t get the displayed value (after selecting a entry from the dropdown) to be my title from the source and not the ID – Only the ID is displayed – in example bellow instead of “Sample A” being displayed in the grid “a” is displayed (after selection – in the dropdown it self it is fine).

    I have implemented the createGridEditor,initGridEditor & gridEditorValue .

    Perhaps in the gridEditorValue function I need to return the title somehow? Does editor object have functions for returning the title?

    The methods –

    var initGridEditor = function (row, cellValue, editor, cellText, width, height) {
    editor.jqxDropDownList(‘selectItem’, cellValue);
    }
    var gridEditorValue = function (row, cellValue, editor) {
    return editor.val();
    }

    The source-
    var actions_1 = [
    {html: “<div style=’padding: 1px;’>Sample A</div>”, title: “Sample A”, value:”a”},
    {html: “<div style=’padding: 1px;’>Sample B</div>”, title: “Sample B”, value:”b”},
    ]
    The column:
    { editable:true,text: ‘Action’,groupable: false, columntype: ‘custom’,datafield: ‘action’,
    createeditor: createGridEditor, initeditor: initGridEditor ,geteditorvalue: gridEditorValue
    },

    Many thanks.


    Peter Stoev
    Keymaster

    Hi assaf.frank123,

    For displaying custom DropDownList, I suggest you to follow this topic: http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/gridkeyvaluescolumnwitharray.htm?arctic

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com


    assaf.frank123
    Participant

    The createGridEditor method will do the following –

    editor.jqxDropDownList({autoDropDownHeight: true, theme: theme, width: width, height: height, source: actions_1 ,valueMember: ‘value’,displayMember: ‘title’});


    Peter Stoev
    Keymaster

    Hi assaf.frank123,

    It should not be necessary to implement gridEditorValue as shown in the sample I pointed you out.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com


    assaf.frank123
    Participant

    Hi Peter,

    There is no “gridEditorValue ” in the sample you gave.
    That is static binding of sources/adapters with ID/NAME.

    I implemented the same way but still I need the 3 methods for the dynamic binding – createGridEditor,initGridEditor & gridEditorValue. These exist in the customrowcelledit.htm.

    Still no change (after changing the binding to adapters rather directly to the array)


    Peter Stoev
    Keymaster

    Hi assaf.frank123,

    if you want to implement “geteditorvalue” for DropDownList associated to a Column with Display/Data fields, then the “geteditorvalue” should return an Object with Label and Value, too – {value: yourValue, label: yourLabel}.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com


    assaf.frank123
    Participant

    Hi Peter,

    Still not working (returning the id into the cell after a value was selected from the dropdown.

    My method is –

    var gridEditorValue = function (row, cellValue, editor) {
    var data = $(‘#jqxgrid’).jqxGrid(‘getrowdata’, row);
    var level = data[“obj”];
    var title = ”;

    if (eval(‘actions_’+level)) {
    for (var i=0;i<eval(‘actions_’+level).length;i++) {
    var curr = eval(‘actions_’+level)[i];

    if (curr.value == editor.val()) {
    title = curr.label;
    }
    }
    }

    return {value: editor.val(), label: title};

    }

    Any idea?

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.