0

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.

Anil
  • 21
  • 5
  • Is the current cell value in the list of values returned by the server? Any space character can be important for the matching. Moreover it can be needed you not use `formatter:'select'` additionally. – Oleg Jun 02 '11 at 07:04

2 Answers2

0

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.

Zachary
  • 6,522
  • 22
  • 34
  • Hi Zachary, Thanks for your reply. HRDept in above code is a string variable which i am populating from server and it contains following string: '101 - Equity Partners:101 - Equity Partners;' and my column contains following value: 101 - Equity Partners but still it dosn't select the drop down value – Anil Jun 02 '11 at 06:05
0

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.

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798