开发者

jqGrid does not selects cell value as a selected dorp down value In edit mode

I am using jqGrid v 4.0 in my application to display tabuler data with Inline edit feature. One of the column in the Grid is a type of "Select". I have populated this select with following server side code:

    //get all Departments
    HRDept = $.ajax({
                        url: '../../PerformanceReview/GetHRDepartments/', 
                        async: false, 
                        success: function(data, result) {
                                    if (!result) 
                                        alert('Failure to retrieve the HR Departments.');
                                 }
                         }).responseText;

I have populated the Grid column with following sysntax:

    name: 'HRDepartment', index: 'Department', align: 'left', editable: true, edittype: 'select', editoptions: {value: HRDept}

But on click of edit button (inline), it shows dropdown on on top of cell but the value is not equal to current cell value. it is always first value of drop down. I had compared the text which i am populating while loading Grid with the text of Dropdown and they are matching.

Could some one开发者_如何学运维 help me to set dropdown value similar as cell value.


Your edit options look wrong, it should be "value:text;" and the value should match your data results.

    { ... editoptions: {value: "HRDept:HR Department;" }}

You can checkout the demo of Row Edition -> Input Types at the jqGrid Demo site., which includes a dropdown list edit cell.


If you get the select values from the server you should use dataUrl option of the editoptions instead of value. Then the jqGrid will make the Ajax request at the beginning of the editing and fill the select element with the server response. It is important to understand that the server response should be in another form:

<select>
    <option value='101 - Equity Partners'>101 - Equity Partners</option>
    …
</select>

If you have already the code on the server which provide the information in another format and you can't change the server code you can define additional buildSelect function which get as the parameter the server response and should return the data in the above format ('...'). See UPDATED part of the answer for the code example.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜