Can't get the object from a cell in jqGrid (jQuery)

This is the issue, when I define the ddl (drop down list or select box) I don't know the selected value. When a user edits a row, the user can select an item from the list. But the selected item isn't set. I want to set the selected item when the user clicks a button to edit the row. The proper way, I think, is to get the ddl that was created when the jqGrid was built and set the selected value. $("#list").jqGrid({ datatype: 'clientSide', colNames: ['Edit', 'Delete', 'Save', 'Cancel', 'Location'], colModel: [ .... .... { name: 'Location', index: 'Location', width: 90, editable: true, edittype: "select", editoptions: { value: SI:System Integration ; IM:Information Management ; IA:Industrial Automation ; CI:Custom Instrumentation}}] }); When the user clicks the edit button I get the data from ddl list var locationText = $("#list").getRowData(rowNum).Location; locationText = Instead of getting the data from the cell in the jqGrid I would rather get the dom ddl element object. The other idea I had, but don't think is right, is to use locationText and use that to create a new ddl dom element. something like this. var locationTmp2 = document.createElement("select"); locationTmp2.innerHTML = locationText; or locationTmp2.text= locationText; Is there an easy way to do what I'm trying to do. I know I could create a new dom select element then add each option to it, like this //populate and set the selected item for locations. var locationSelect = document.createElement("select"); var arrayLocations = ('R:Rochester;MA:Massachusetts;DL:Data Librarian;Buff:Buffalo/Niagara Falls;Bing :Binghamton / Owego / Southern Tier;Other:All other locations;Alb:Albany and all points East;').split(";"); for (var i = 0; i < arrayLocations.length - 1; i++) { var optionItem = document.createElement("option"); optionItem.value = trim(arrayLocations[i].split(":")[0]); optionItem.text = trim(arrayLocations[i].split(":")[1]); //check if this should be the selected item. if (arrayLocations[i].indexOf(rowData.Location) != -1) optionItem.selected = true; locationSelect.add(optionItem); } but there should be a way to grab the entire dom element from jqGrid. Thanks
Does jqGrid have built-in row edit functionality? Does it create the drop-down for you when the user clicks edit or do you have to do that yourself?

以上就是Can't get the object from a cell in jqGrid (jQuery)的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » jQuery 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准