Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

jQuery EasyUI DataGrid - Extending Editors

jQuery EasyUI DataGrid - Extending Editors

Some common editors are added to the datagrid so that users can edit data. All editors are defined in the $.fn.datagrid.defaults.editors object, which can be extended through inheritance to support new editors. This tutorial will show you how to add a new numberspinner editor to the datagrid.

Extend the numberspinner editor through inheritance



    $.extend($.fn.datagrid.defaults.editors, {

        numberspinner: {

            init: function(container, options){

                var input = $('').appendTo(container);

                return input.numberspinner(options);

            },

            destroy: function(target){

                $(target).numberspinner('destroy');

            },

            getValue: function(target){

                return $(target).numberspinner('getValue');

            },

            setValue: function(target, value){

                $(target).numberspinner('setValue',value);

            },

            resize: function(target, width){

                $(target).numberspinner('resize',width);

            }

        }

    });

Create a DataGrid in HTML markup



    

        

            

                

                

                

                

                

                

            

        

    
Item IDList PriceUnit CostAttributeStatusAction

We assign the numberspinner editor to the 'unit cost' field. When a row starts being edited, the user can edit the data through the numberspinner editor.

Download the jQuery EasyUI example

jeasyui-datagrid-datagrid23.zip