Title: Problem with true and false words in editors Post by: r2ferna on October 23, 2013, 12:01:22 PM I have this piece of code:
<thead> <tr> <th field="Menu" width="150">Menú</th> <th field="SubMenu" width="150">SubMenú</th> <th field="Opcion" width="150">Opción</th> <th field="autorizado" width="80" align="center" editor="{type:'checkbox', options:{on:true, off:false}}">¿Ver?</th> <th field="p-gp" width="90" align="center" editor="{type:'checkbox', options:{on:'true', off:'false'}}">¿Guardar?</th> </tr> </thead> and this is an extract of the json file loaded in the datagrid: { "Menu": "Mantenimiento", "SubMenu": "Mantto. Codigos", "Opcion": "Codigos", "p-gp": true, "autorizado": false }, { "Menu": "Mantenimiento", "SubMenu": "Mantto. Codigos", "Opcion": "Subtotales", "p-gp": true, "autorizado": false } As you can see: the "autorizado" and "p-gp" fields are logical fields. This editors don't function!! editor="{type:'checkbox', options:{on:true, off:false}}">¿Ver?</th> editor="{type:'checkbox', options:{on:'true', off:'false'}}">¿Guardar?</th> Both editors show the checkbox, but if the field-value is 'true' they don't show the checkmark!? Can you help me, please? PD. If I change the value of those fields to 'Si' and 'No' words, all works OK!! So the problem occurs only with the 'true' and 'false' words. I know this is a confusion between logical and string fields but I don't know how to solve it. Thanks!! Title: Re: Problem with true and false words in editors Post by: stworthy on October 23, 2013, 05:28:47 PM Please try to change the "autorizado" and "p-gp" fields to string fields.
Code: { Title: Re: Problem with true and false words in editors Post by: r2ferna on October 28, 2013, 11:33:05 AM Thanks stworthy!
I changed the field to string Fields. Now I'm faced to another issue: This function tries to apply, the changes made to an row, to some other datagrid rows. function hacerCambioMasivo(rowIndex,rowData,rowChanges){ cMeP = true; var llaveControl = rowData.Menu + (rowData.SubMenu || ''); var rows = $('#dgP').datagrid('getRows'); $.each(rows, function(i,row) { var llaveRow = row.Menu + (row.SubMenu || ''); if (llaveRow == llaveControl) { $('#dgP').datagrid('beginEdit', i); $('#dgP').datagrid('updateRow',{ index: i, row: rowChanges, }); $('#dgP').datagrid('endEdit', i); } }); cMeP = false; } Yeah! I get the rows changed and refreshed (with datagrid-updateRow method) but this piece of code: function aceptaCambios() { var rowsCh = $('#dgP').datagrid('getChanges'); console.log(rowsCh.length, rowsCh); } Only shows one (1) changed row!! (the row who originated the massive changes - the row on wich I clicked the changes) the rows changed by the function code arn't counted as changed! What can I do for? PD: the function is fired at datagrid's onAFterEdit : onBeforeEdit:function(rowIndex,rowData) { if (!cMeP) { var tipoMenu = investigaTipoMenu(rowData); if (tipoMenu != 'Opcion') { // Es Menu o SubMenu var msje = "¡Los cambios efectuados en este " + tipoMenu + " serán aplicados a TODAS las opciones de dicho " + tipoMenu + "."; $.messager.alert("Aviso", msje, "info"); } rowData.editing = true; updateActions(rowIndex); } }, onAfterEdit:function(rowIndex,rowData,rowChanges){ console.log("Changes for row ", rowIndex, rowChanges); if (!cMeP) { var tipoMenu = investigaTipoMenu(rowData); if (tipoMenu != 'Opcion') { // Es Menu o SubMenu hacerCambioMasivo(rowIndex, rowData, rowChanges); } rowData.editing = false; updateActions(rowIndex); } }, and this are the datagrid columns definitions: <th field="p-vp" width="80" align="center" formatter="formatVer" editor="{type:'checkbox', options:{on:'Si', off:'No'}}">¿Ver?</th> <th field="p-gp" width="90" align="center" formatter="formatGuardar" editor="{type:'checkbox', options:{on:'Si', off:'No'}}">¿Guardar?</th> MTIA. |