jQWidgets Forums

jQuery UI Widgets Forums Grid ValueMember in dropdown list column

This topic contains 5 replies, has 2 voices, and was last updated by  Dimitar 12 years, 8 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
  • ValueMember in dropdown list column #11449

    Mark
    Member

    Hi,

    I am having an issue getting the valueMember from a data drop a dropdownlist in my grid. My Save routine works on the dataAdapter however the value for this column is set to the displayMember value.

    My grid is set up as follows

     var capture_source = {
    datatype: "json",
    type: "POST",
    data: html,
    datafields: [
    { name: 'Scope' },
    { name: 'ID' },
    { name: 'Type' },
    { name: 'Text' },
    { name: 'Value' },
    { name: 'ElementID' }
    ],
    url: '@ViewBag.URL/Admin.svc/ParseCaptures',
    updaterow: function (rowid, rowdata, result) {
    debugger;
    //alert("Update");
    //result(true);
    }
    }
    this.da_Capture = new $.jqx.dataAdapter(capture_source, {
    downloadComplete: function (data, status, xhr) { },
    loadComplete: function (data) { },
    loadError: function (xhr, status, error) { alert(error); }
    })
    var element_source = {
    datatype: "json",
    datafields: [
    { name: 'ElementID' },
    { name: 'Name' }
    ],
    url: '@ViewBag.URL/Admin.svc/Elements'
    }
    var da_element = new $.jqx.dataAdapter(element_source, { autoBind: true, async: false });
    $("#grd_Capture").jqxGrid({
    source: this.da_Capture,
    theme: theme,
    width: '660px',
    height: '150px',
    pageable: false,
    columnsresize: true,
    selectionmode: 'singlecell',
    autoheight: true,
    editable: true,
    sortable: false,
    altrows: true,
    enabletooltips: true,
    columns: [
    //{ text: 'Action', width: 50, cellsrenderer: actionrenderer },
    { text: 'Scope', datafield: 'Scope' },
    { text: 'Type', datafield: 'Type' },
    { text: 'ID', datafield: 'ID' },
    { text: 'Text', datafield: 'Text' },
    { text: 'Value', datafield: 'Value' },
    {
    text: 'Element', datafield: 'ElementID', columntype: 'dropdownlist', width: 300,
    createeditor: function (row, cellvalue, editor) {
    editor.jqxDropDownList({ displayMember: 'Name', valueMember: 'ElementID', source: da_element, theme: theme });
    editor.jqxDropDownList('insertAt', { label: '(new)', value: '0' }, 0);
    editor.jqxDropDownList('insertAt', { label: '[Ignore]', value: '0' }, 0);
    editor.jqxDropDownList('selectIndex', 0);
    }
    }
    ]
    });

    Now, when a user clicks on a save I call the following to iterate the data source to get the information out (and most importantly the ElementID (valueMember) that has been selected by the user when he picked the Element Name (displayMember).

    ….
    ….

                var Captures = [];
    for (var i = 0; i < da_Capture.totalrecords; i++) {
    Capture = {};
    Capture.Scope = da_Capture.records[i].Scope;
    Capture.Type = da_Capture.records[i].Type;
    Capture.ID = da_Capture.records[i].ID;
    Capture.Text = da_Capture.records[i].Text;
    Capture.ElementID = da_Capture.records[i].ElementID;
    Captures.push(Capture);
    }

    ….
    ….

    Thanks

    Mark

    ValueMember in dropdown list column #11451

    Dimitar
    Participant

    Hello Mark,

    After edit, the grid cell gets only the displayMember value of the selection in the editor.

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

    ValueMember in dropdown list column #11470

    Mark
    Member

    Thanks Dimitar,

    Can you think of a workaround I can apply here to ultimately store the data from the valueMember in the underlying dataAdapter, or is the only way I can do this is to capture the display data and look up it’s ID in code on the server side?

    Thanks

    Mark

    ValueMember in dropdown list column #11514

    Dimitar
    Participant

    Hi Mark,

    Unfortunately, we cannot provide you with workaround on the matter.

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

    ValueMember in dropdown list column #11580

    Mark
    Member

    Thanks Dimitri

    Do you know if this will be added to the product roadmap as I suspect that a lot of people will find this very useful?

    Cheers

    Mark

    ValueMember in dropdown list column #11689

    Dimitar
    Participant

    Hi Mark,

    With jQWidgets’s newest version, 2.5.5, the demo Keys/Values Column is available. It showcases a similar functionality.

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

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

You must be logged in to reply to this topic.