jQWidgets Forums

jQuery UI Widgets Forums TreeGrid TreeGrid with Dropdownlist In Edit mode

This topic contains 3 replies, has 2 voices, and was last updated by  Martin 6 years, 4 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • TreeGrid with Dropdownlist In Edit mode #103955

    gjlabus
    Participant

    Hi

    I have been able to add a dropdownlist in the TreeGrid. When the grid loads the Column Text is showing successfully as displayField: ‘AccountName’ with the Id added as dataField: ‘AccountId’.

    When I click on the grid to edit the row and change the value of the dropdownlist, the value is saved correctly to the database but the text shown in the grid changes to the Id. How can I keep the text as AccountName and not the Id?

    columns: [
    {
    text: ‘Control Account’, dataField: ‘AccountId’, displayField: ‘AccountName’, width: 300, columnType: “template”,
    createEditor: function (row, cellvalue, editor, cellText, width, height) {
    // construct the editor.
    editor.jqxDropDownList({ autoDropDownHeight: true, source: dataAdapterCashContractsList, displayMember: “AccountName”, valueMember: “Id”, width: width, height: ‘100%’ });
    },
    initEditor: function (row, cellvalue, editor, celltext, width, height) {
    // set the editor’s current value. The callback is called each time the editor is displayed.
    editor.jqxDropDownList(‘selectItem’, cellvalue);
    },
    getEditorValue: function (row, cellvalue, editor) {
    // return the editor’s value.
    return editor.val();
    }
    },
    { text: ‘Account Number’, dataField: ‘BankNumber’, filterable: false, width: ‘200’ },
    { text: ‘Active’, dataField: ‘Active’, filterable: false, width: ’80’ }
    ]

    TreeGrid with Dropdownlist In Edit mode #103965

    Martin
    Participant

    Hello gjlabus,

    Please, look at the following Example.

    Best Regards,
    Martin

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

    TreeGrid with Dropdownlist In Edit mode #103997

    gjlabus
    Participant

    Thank you. This is great but I now have another challenge. I need to return the Id to update the database. With the name being returned, I cannot update the database using JSON.

    The Id of the drop-down is not the same as the rowid.

    Database table example

    Main grid table
    —————
    rowid: 3
    AccountId: 6 (Value from dropdownlist. This value comes from another table.)
    BankName: Nedbank
    BankNumber: 123456

    Dropdownlist table
    —————-
    Id: 6
    AccountName: Cash In Bank

    TreeGrid with Dropdownlist In Edit mode #104038

    Martin
    Participant

    Hello gjlabus,

    I would suggest you to create a dictionary object in which you will keep the corresponding id-s of the grid and the dropdownlist and use it for returning the correct id to the database.

    Best Regards,
    Martin

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

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

You must be logged in to reply to this topic.