EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: iskandarkbr on March 12, 2015, 12:27:39 AM



Title: multiSelect row ctrl and cellediting
Post by: iskandarkbr on March 12, 2015, 12:27:39 AM
is your http://www.jeasyui.com/easyui/plugins/jquery.datagrid.js conflict with cellEditing below?
becouse when i included your jquery.datagrid.js it said "TypeError: value is undefined" for the numeric field that i define its formatter.


$.extend($.fn.datagrid.methods, {
   editCell: function(jq,param){
      return jq.each(function(){
         var opts = $(this).datagrid('options');
         //console.log(opts);
         var fields = $(this).datagrid('getColumnFields',true).concat($(this).datagrid('getColumnFields'));
         for(var i=0; i<fields.length; i++){
            var col = $(this).datagrid('getColumnOption', fields);
            col.editor1 = col.editor;
            if (fields != param.field){
               col.editor = null;
            }
         }
         $(this).datagrid('beginEdit', param.index);
         var ed = $(this).datagrid('getEditor', param);
         if (ed){
            if ($(ed.target).hasClass('textbox-f')){
               var str=$(ed.target).textbox('getText');
               $(ed.target).textbox('textbox').setSelection(0,str.length);
               $(ed.target).textbox('textbox').focus();
            } else {
               $(ed.target).focus();
            }
         }
         for(var i=0; i<fields.length; i++){
            var col = $(this).datagrid('getColumnOption', fields);
            col.editor = col.editor1;
         }
      });
   },
   enableCellEditing: function(jq){
      return jq.each(function(){
         var dg = $(this);
         var opts = dg.datagrid('options');
         opts.oldOnClickCell = opts.onClickCell;
         opts.onClickCell = function(index, field){
            if (opts.editIndex != undefined){
               if (dg.datagrid('validateRow', opts.editIndex)){
                  dg.datagrid('endEdit', opts.editIndex);
                  opts.editIndex = undefined;
               } else {
                  return;
               }
            }
            dg.datagrid('selectRow', index).datagrid('editCell', {
               index: index,
               field: field
            });
                     
            opts.editIndex = index;
            opts.oldOnClickCell.call(this, index, field);
         }
      });
   }
});


Title: Re: multiSelect row ctrl and cellediting
Post by: iskandarkbr on March 12, 2015, 01:32:41 AM
when i use --> url:'datajson.php' it problem on its value formatter.
but when i use variabel var dataGrid={"total":28,"rows":[..........]} it doesnt problem


Title: Re: multiSelect row ctrl and cellediting
Post by: stworthy on March 12, 2015, 02:29:52 AM
How do you declare your numeric editor and the 'formatter' function? Please show your code snippets out.


Title: Re: multiSelect row ctrl and cellediting
Post by: iskandarkbr on March 12, 2015, 02:36:29 AM
here my field definision

{field:'unitcost',title:'Unit Cost',width:80,align:'right',editor:'numberbox',
   formatter:function(value, row){
         var strAngka=value.toString();
         return (strAngka);
   }
},


Title: Re: multiSelect row ctrl and cellediting
Post by: aswzen on March 12, 2015, 02:43:26 AM
i don't know what is going on in 1.4.2 but before updated this console.log code

Quote
formatter:function(value, row, index){
         console.log(value);
         return (value);
   }

will return the value normally..but now it will return error like "TypeError: value is undefined"

by the way you can solve this problem with this code
Quote
formatter:function(value, row, index){
         console.log(value+"");
         return (value);
   }

and on your code will be
Quote
{field:'unitcost',title:'Unit Cost',width:80,align:'right',editor:'numberbox',
   formatter:function(value, row){
         var strAngka=value+'';
         return (strAngka);
   }
}

well :/


Title: Re: multiSelect row ctrl and cellediting
Post by: iskandarkbr on March 12, 2015, 02:47:19 AM
i tried to modify your example, i replace data:data by url:'data_json.php'


Title: Re: multiSelect row ctrl and cellediting
Post by: iskandarkbr on March 12, 2015, 02:55:03 AM
i'ved tried your trick value+'' , its works.
i think , maybe, toString() is the problem :) :)


Title: Re: multiSelect row ctrl and cellediting
Post by: iskandarkbr on March 12, 2015, 06:28:44 PM
it seems, now, your new jquery.datagrid.js error while execute 'enableCellEditing' function

TypeError: $.fn.datagrid.methods[_195] is not a function
return $.fn.datagrid.methods[_195](this,_196);

does it conflict among your EasyUI 1.4.2 and 1.4.1 when i include it together. i made function for combotree (in 1.4.1), but it not execute in 1.4.2


Title: Re: multiSelect row ctrl and cellediting
Post by: stworthy on March 12, 2015, 06:59:55 PM
Please try the attached example 'test.html'. It works fine.


Title: Re: multiSelect row ctrl and cellediting
Post by: iskandarkbr on March 18, 2015, 08:12:44 PM
its not work after datagrid.js combine with editdatacell..js