You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a piece of code that was working fine with and earlier version of jqGrid(pre the fork) and when I attempted to upgrade it the formatter function stopped working.
Sorry for the late answer. Please, post always the version of jqGrid, which you use. Please, describe the problem more detailed, so that I could reproduce the problem. It's strictly recommended to post the demo (in JSFiddle, for example) which could I use to reproduce the problem and to debug it.
Your current JavaScript code is very dirty. The formatter generate wrong formatted HTML fragment, because the closing </select> is missing. Additionally the column has property editable: true. It's unclear for me how you plan to combine select displayed in the main grid with editing of data. The select looks for the user as if one can change the value directly without starting any editing. If the user makes the changes then jqGrid don't get any information about that. One can implement the code, which displays interactive element like select or chechbox without enable editing, but it's a little tricky. See the answer for references to a possible solution. I'm not sure that you use the grid correctly, but I'm not sure and I can't gives you any advices without seeing more full code.
The picture, which you posted seems as if multiple rows are in editing. When you have the problem? At the beginning by initial displaying the grid or later during starting some editing mode (inline editing or cell editing)?
In any way if you define custom formatter and use use editable: true, then you have to define unformat too (see here). Unformatter will be used by jqGrid to get the data from a custom formatted cell. The editing data will be the content of the cell if no unformat is defined. In the case you can have the results close to the results displayed on your picture.
I have a piece of code that was working fine with and earlier version of jqGrid(pre the fork) and when I attempted to upgrade it the formatter function stopped working.
Code snippet:
function preferredSelect(cellvalue,options,rowObj) { var id = rowObj.contactid; var current=cellvalue; console.log(cellvalue); console.dir(options); console.dir(rowObj); if(cellvalue==undefined) id=newRow; var str = "<select id=\"ispref_"+id+"\">"; if(cellvalue=="N") str +="<option SELECTED value=\"N\">N</option>"; else str +="<option value=\"N\">N</option>"; if(cellvalue=="Y") str +="<option SELECTED value=\"Y\">Y</option>"; else str +="<option value=\"Y\">Y</option>"; console.log(str); return str;
From definition:
` {
name: 'ispreferred',
index: 'ispreferred',
editable:true,
formatter:preferredSelect,
width: 140,
userdata:'userdata',
cellattr: function(rowId,val,rawObject,cm,data) {
},
sorttype: "text"
},
`
Example output, note instead of a select element, the text is printed. What changed?
The text was updated successfully, but these errors were encountered: