Forum
00:44
14/02/2013
After updating from v4.4.4 to v4.7.0 I noticed some things aren't working as before:
1) After saving in form edit, the grid displays the id's of the combos instead of the text.
2) If I set id in prmNames, when saving in edit form the row number is set in postdata instead of the actual value.
 Here's an example of my col model definition:
  prmNames: {id: "idPer", search:null, nd : null, page: null, rows: null, sort : null, order : null}, Â
  colNames:['idPer', 'person', 'idCity', 'age', 'employee', 'employee 2', 'birth date', 'idGroup', 'Desc','Obs'], Â
  colModel:[
   {name:'idPer',index:'idPer', hidden: true, key: true, width:55, editable:true, editrules:{edithidden:false}, sorttype:'int'},
   {name:'person,index:'person', editable:true, editoptions:{size:39}, width:190, sorttype:'text'},
   {name:'idCity',index:'idCity', hidden: true},
   {name:'age',index:'age', editable:true, edittype:'select',
    editoptions:{ Â
     dataUrl:"myUrl",
     buildSelect: myFunction)
     },           Â
     width:90, sorttype:'text'},   Â
   {name:'employee',index:'employee', editable:true, edittype:'select', formatter:eFmatter, unformat:eUnFmatter,Â
     width:190, sorttype:'text'},
   {name:''employee2',index:''employee2', editable:true, edittype:'select', formatter:eFmatter, unformat:eUnFmatter,Â
     width:190, sorttype:'text'},     Â
   {name:'birth',index:'birth', width:90, sorttype:'date', formatter:'date', editable:true},
   {name:'idGroup',index:'idGroup', hidden: true},
   {name:'desc',index:'desc', width:190, formatter:dFmatter, unformat: dFmatter,editable:true, edittype:'select',
     editoptions:{
     dataUrl:"myurl2",
     buildSelect: myfunction2)
     },              Â
     sorttype:'text'},
   {name:'obs',index:'obs', width:190, editable:true, sorttype:'text', edittype:'textarea', editoptions:{rows:2, cols:40}}]
Â
Did I missed something with the new releases?
Thanks in advance
14:24
10/08/2009
To fix the problem one have to debug the code. So one needs to have the working demo which uses uncompressed version of jqGrid jquery.jqGrid.src.js (instead of jquery.jqGrid.min.js). If one can see that wrong information will be posted to the server that one don't need and server part to debug such demo. So please prepare always a working demo if you report the bug.
About the first issue which you report all sounds very strange. You write about "the id's of the combos instead of the text". So you use probably select with options having different value and the text. It seems me wrong if you use edittype:'select' and not uses formatter:'select'. One uses different values and texts in select options only in the case that one fill the data with ids (values), but one want to display the texts for the user. formatter:'select' do that. The only disadvantage of the approach is that the formatter have to know the mapping between ids and the texts during filling of the grid. One can't make an additional asynchronous call to the server. So one uses formatter:'select' with editoptions.value instead of usage of editoptions.dataUrl. If one need still build dynamic values of editoptions.value one can set it inside of beforeProcessing callback. See the answer for more details.
About the problem with the date format you should try to use reformatAfterEdit: true option of formatter: "date".
Best regards
Oleg
19:07
14/02/2013
Thanks for your response. I've never used jsfiddle and I don't know how to simulate ajax requests (apparently only POST is supported and I'm using GET). Anyway here's a small demo:
HTML Body:
   <div>
      <table id="sampleGrid"><tr><td></td></tr></table>
      <div id="pagerSampleGrid"></div>  Â
   </div>
Javascript:
   //<![CDATA[
       $(document).ready(function () {          Â
           setjqGridSettings();
           setGridRequirentes();          Â
       });
  Â
function setjqGridSettings()
{Â Â Â
   $.extend($.jgrid.defaults,
   {
      mtype:"POST",                   Â
      datatype: 'json',
      ajaxGridOptions: { contentType: "application/json; charset=utf-8" },  Â
      viewrecords: true,
      loadonce: true,
      gridview: true,
      scrollOffset: 0,
      autowidth: true,
      ignoreCase: true,
      jsonReader : {
          root: "d.rows",
          page: "d.page",
          total: "d.total",
          records: "d.records",
          cell: ""},
      ajaxSelectOptions: { type: "GET", contentType: 'application/json; charset=utf-8' }
   });
   $.extend($.jgrid.edit,
   {
      ajaxEditOptions: { contentType: "application/json; charset=utf-8" },
      closeAfterEdit: true,
      closeAfterAdd: true,
      closeOnEscape: false,
      reloadAfterSubmit: false,
      jqModal: false
   });  Â
}Â Â Â
  Â
function setGridRequirentes()
{Â Â Â
   var modSettings =
   {
      width: 440,
      url: 'myUrl.aspx',
      serializeEditData: function(postData) {        Â
         console.log(postData)
      }     Â
   };
   var sampleData = [
           {idPer:"13570", person:"some name 1",idCity:"Washington"},
           {idPer:"34233", person:"some name 2",idCity:"Australia"},
       ];         Â
        Â
   $("#sampleGrid").jqGrid({      Â
       //datatype:'local',
       //data: sampleData,
      url: "MyPage.aspx/getPeople",  Â
      mtype: "GET",      Â
      prmNames: {id: "idPer", search:null, nd : null, page: null, rows: null, sort : null, order : null}, Â
      colNames:['idPer', 'person', 'idCity'], Â
      colModel:[
         {name:'idPer',index:'idPer', hidden: true, key: true, width:55, editable:true, editrules:{edithidden:false}, sorttype:'int'},
         {name:'person',index:'person', editable:true, editoptions:{size:39}, width:190, sorttype:'text'},
         {name:'idCity',index:'idCity', editable:true, edittype:'select',
            editoptions:{ value:"1:London;2:Washington;3:Australia"},width:90, sorttype:'text'}],
      rowNum:5,
      rowList:[5,10,15,20],
      pager: '#pagerSampleGrid',  Â
      caption:"Sample Grid"     Â
   });  Â
Â
   $("#sampleGrid").jqGrid('navGrid','#pagerSampleGrid',{edit:true,add:true,del:false,search:false,refresh:false},modSettings);
}
   //]]>
Â
The response from my web service getPeople is (I'm using the format suggested in jqGrid demos "Data Mapping"->"Data Optimization" to reduce the size of the response):
{"d":{"page":1,"total":1,"records":100,"rows":[["13570","Some name 1","Australia"],["34233","Some name
2","Washington"]]}}
In serializeEditData I only get the number of the row instead of the "idPer" value as can be seen in the console.
Also note that after saving (gives an error since the webservice is not found) for example Australia is replaced by 3.
Thanks for your help
03:32
14/02/2013
Here's the jsfiddle:
The only thing that is missing is the Ajax response. I found the following example, but I don't know how to use it to replace the Ajax call in jqgrid:
new Request.JSONP({
   url: 'http://jsfiddle.net/echo/jsonp/',
   data: {
       text: 'some text',
       par1: 'another text'
   },
   onSuccess: function(response) {
       show_response(response, $('post'));
   }
}).send();
08:28
10/08/2009
If you have an interest to prepare the jsfiddle demo which uses Ajax you can use http://jsfiddle.net/OlegKi/ntfw57zm/ as an example.
I can repeat that I think that you use wrong value editoptions:{ value:"1:London;2:Washington;3:Australia"}. You use "Australia" and "Washington" in the input data. So you don't use ids in the input data. It means that editoptions:{ value:"London:London;Washington:Washington;Australia:Australia"} will be correct.
If you do want to use ids in the idCity column you should use [["13570","Some name 1","3"],["34233","Some name2","Washington"]] and
colNames: ['person', 'idCity'], colModel: [ {name:'person', editoptions:{size:39}, width:190}, {name:'idCity', edittype:'select', formatter:'select', width:90, editoptions:{ value:"1:London;2:Washington;3:Australia"}} ], cmTemplate: {editable:true}
In the way the data will hold only ids in idCity column but display texts. formatter:'select' do the mapping. Because you use prmNames: {id: "idPer", ...} no hidden idPer column is required.
Best regards
Oleg
16:22
14/02/2013
Here's the jsfiddle for the issue with prmNames (I removed the hidden:true property for column idPer. In edit form the value is displayed correctly, after saving is replaced by the number of the row):
http://jsfiddle.net/d26hzhu6/2/
Notice that if you remove the property id: "idPer" in prmNames this problem is fixed.
Also the same code works correctly in v4.4.4, as you can see in the fiddler used below.
Â
Regarding the issue with the combos:
I was using version 4.4.4. I know it may sound strange, but it was working as I previously explained without formatter:'select':
I retrieve from the DB the text "Australia" for the field "idCity". When opening the edit form, jqgrid will match the text to positionate the combo. After successfull submit (which post idCity=3) the text "Australia" would appear in the grid instead of the value 3.
Here's the jsfiddle using v.4.4.4 exposing the behaviour I mentioned above:
http://jsfiddle.net/Lgy7ae3h/1/
After comparing the code in formedit I found that in version 4.4.5 some code was removed that provided that functionality (all related to a var name "expost"). I also found the commit of that change:
https://github.com/tonytomov/jqGrid/commit/edb5073b6bd617878221674d201cba060489241c
Now, how can I update my code to make it work as before but using the new version?. I have more than 20 grids and I would try to avoid to change the stored procedures.
21:06
10/08/2009
Hi,
usage of demos simplify all. The reason of the problem with sending wrong idCity - the rowids of the grid will be wrong assigned. It's a bug in jqGrid. The bug exists in combination of the usage of arrays of strings as the input value of row like ["13570","Some name 1","Australia"] and the usage of key:true property in colModel. I will post later to github my suggestion how to fix the problem. As the workaround I suggest you to add jsonReader : {id: 0} option and remove key:true property from the first column definition.Â
See http://jsfiddle.net/OlegKi/d26hzhu6/3/
About the problem with the requirement to post idCity=3 instead of the text "Australia" I wrote you two times before. You used wrong configuration which worked in old versions of jqGrid, but the but are fixed some years ago (probably in the version 4.4.5). So you should decide whether you want that jqGrid hold values like 1,2,3 in idCity column (and displays still the texts "London", "Washington", "Australia") or you use the texts "London", "Washington", "Australia" in the data. In the first case you the communication with the server will be in ids 1,2,3, but the values have to be used in both input of grid and the output. Exactly the example I used in the modified demo. Alternatively you can fill jqGrid with the data like "London", "Washington", "Australia", but exactly the same data will be send to the server during editing.
You still can use serializeEditData to remap any standard values like "London", "Washington", "Australia" to 1,2,3 or on the contrary, but I don't recommend you to do so because I personally find such kind on communication transfer non-consequent.
Best regards
Oleg
02:16
10/08/2009
Hello Tony,
I posted the pull request which contains the changes in addJSONData and normalizeData required to fix problem with the usage key:true in combination with the reader (jsonReader or localReader) having repeatitems:true.
Here is the modified version of jquery.jqGrid.src.js.
The problem come after you changed old keyIndex option to keyName. It was done to fix problem with non-updated keyIndex option after resorting columns in jqGrid (by usage columnChooser or drag and drop of column headers in case of the usage sortable:true).
I hope that I tested all possible cases.
Best regards
Oleg
Most Users Ever Online: 715
Currently Online:
45 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66