jQWidgets Forums

jQuery UI Widgets Forums Grid cell edit problem about dropdownlist

This topic contains 12 replies, has 2 voices, and was last updated by  yuanru 10 years, 3 months ago.

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
  • cell edit problem about dropdownlist #66594

    yuanru
    Participant

    theme: “custom”,
    altrows: true,
    width: “100%”,
    height: 200,
    columnsresize: true,
    showstatusbar: true,
    editable: true,
    editmode: ‘click’,
    localization: getLocalization(‘zh’),
    columns: [
    { text: ‘date’, datafield: ‘eva_date’, width: 180,
    columntype: ‘dropdownlist’,
    createeditor: function (row, value, editor) {
    editor.jqxDropDownList({ source: lessonsAdapter, displayMember: ‘date’, valueMember: ‘date’});
    }
    },
    { text: ‘score’, datafield: ‘eva_score’, width: 60,
    columntype: ‘dropdownlist’,
    createeditor: function (row, value, editor) {
    editor.jqxDropDownList({ source: scoresAdapter, displayMember: ‘label’, valueMember: ‘value’});
    }
    },
    { text: ‘comment’, datafield: ‘eva_comment’ }
    ],

    Hi, there is a problem in the above setting.
    When I click the cells in the [score] column, it’s ok. But when I click one cell in [date] column, I meet a problem.

    Details: The problem only emerge when I first click a cell in [date] column. The dropdownlist’s default item is not the value item in the cell. It displays ‘Please Choose:’. After the first click, everything is fine. That is to say, if I click other cells in the [date] column, the default item in the dropdownlist is right after the first click.

    And I set the dropdownlist’s parameter selectedIndex to be a fixed number, like 3. The parameter selectedIndex seems to have no effect to the dropdownlist. The dropdownlist’s default item is also ‘Please Choose’.

    In order to fix it, I spend a lot of time. I add some debug information in the function [createeditor: function (row, value, editor)], but the debug information only displayed once when I first click one cell in [date] column. I don’t know if it is right.

    And this problem emerges in Chrome. When I use Firefox, the problem disappeared.

    Could someone please help me with the problem? Thanks!

    cell edit problem about dropdownlist #66597

    yuanru
    Participant

    by the way. I just upgrade my Firefox. The problem emerge again…

    cell edit problem about dropdownlist #66599

    Peter Stoev
    Keymaster

    Hi yuanru,

    This is not a problem with jqxDropDownlist’s editor. You are creating Custom Editor. That custom Editor has custom Data Source and you missed to implement the “initeditor” function which is for setting the current selected item. “createeditor” according to the documentation is called once only.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    cell edit problem about dropdownlist #66602

    yuanru
    Participant

    Hi Peter,

    Thanks for your reply. While the [score] column’s source is also custom Data Source. But it’s ok.

    Could you please give me an example how to implement the “initeditor” function or a webpage helping me how to implement. Because I didn’t find “initeditor” in the API reference of dropdownlist.

    cell edit problem about dropdownlist #66603

    yuanru
    Participant

    initeditor: function (row, cellvalue, editor, celltext, pressedChar) {
    /*
    var key = -1;
    for(key in lessonsAdapter.records)
    if (lessonsAdapter.records[key].date == cellvalue)
    break;
    */
    editor.jqxDropDownList({
    selectedIndex: 2
    });
    },

    I add the initeditor, but the problem is not fixed.

    cell edit problem about dropdownlist #66605

    Peter Stoev
    Keymaster

    Hi yuanru,

    You will not find initeditor in the DropDownlist because initeditor is a Column property. You’re using DropDownList Editor in jqxGrid and you should use the jqxGrid’s API for customizing Editors. I would suggest you also if you experience issue, to share jsfiddle.net sample which demonstrates it. Sharing only parts of your code does not help us, because we cannot test your scenario.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    cell edit problem about dropdownlist #66607

    yuanru
    Participant

    Hi Peter,

    Thanks for your quick reply.
    Please check the following url.
    http://125.67.20.10:8888/ytb_phalcon/ytb/total?ytb_classid=280

    You can select rows of the first grid. Then the second grid would show some contents. The second grid could be edited.
    The column called ‘日期’ has the problem I said.

    cell edit problem about dropdownlist #66609

    Peter Stoev
    Keymaster

    Hi yuanru,

    As far as I see, the key is equal to -1 when you click i.e you set the selected index to -1 which displays the widget’s placeHolder – Please Choose.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    cell edit problem about dropdownlist #66611

    yuanru
    Participant

    Hi Peter,

    Perhaps I find the cause. The ‘日期’ column dropdownlist’s dataAdapter data is from the server. When I make it from localdata, the problem doesn’t appear.

    Is it a dataAdapter problem?

    cell edit problem about dropdownlist #66615

    Peter Stoev
    Keymaster

    Hi yuanru,

    No, it’s not a dataAdapter problem, it’s logical problem. I think this happens because you load data through Ajax and you try to find a Key while your data is actually Still Loading and that’s why your Key is -1. If you want to load data through Ajax and ensure that it’s loaded, may be you should make the selection after your data is loaded and set async: false of your adapter’s source object, then after the data is loaded, find the key and select the appropriate DropDownList index.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    cell edit problem about dropdownlist #66617

    yuanru
    Participant

    Hi Peter,

    I have tested if I set param ‘key’ to a fixed number(2) and set sync:false in dataAdapter. But the result is also the same.

    cell edit problem about dropdownlist #66619

    Peter Stoev
    Keymaster

    Hi yuanru,

    Ok, send us a jsfiddle.net sample which we would be able to update and Fork and we will tell you what’s wrong in the code.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    cell edit problem about dropdownlist #66626

    yuanru
    Participant

    Hi Peter,

    Thanks for your help during the whole process.
    Finally you are right, set async:false is effective. I made a mistake just now.

    Best Regards

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

You must be logged in to reply to this topic.