原創|使用教程|編輯:龔雪|2016-02-29 08:56:17.000|閱讀 676 次
概述:jQuery EasyUI允許一些常見的編輯器添加到數據網格中,以便用戶編輯數據。所有的編輯器都定義在$.fn.datagrid.defaults.editors對象中,這個可以繼承擴展以便支持新的編輯器。本教程將向您展示如何添加一個新的numberspinner編輯器到數據網格中。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
Kendo UI for jQuery——創建現代Web應用程序的最完整UI庫!查看詳情>>>
jQuery EasyUI允許一些常見的編輯器添加到數據網格中,以便用戶編輯數據。所有的編輯器都定義在$.fn.datagrid.defaults.editors對象中,這個可以繼承擴展以便支持新的編輯器。本教程將向您展示如何添加一個新的numberspinner編輯器到數據網格中。
$.extend($.fn.datagrid.defaults.editors, { numberspinner: { init: function(container, options){ var input = $('<input type="text">').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); } } });
<table id="tt" style="width:600px;height:250px" url="data/datagrid_data.json" title="Editable DataGrid" iconCls="icon-edit" singleSelect="true" idField="itemid" fitColumns="true"> <thead> <tr> <th field="itemid" width="60">Item ID</th> <th field="listprice" width="80" align="right" editor="{type:'numberbox',options:{precision:1}}">List Price</th> <th field="unitcost" width="80" align="right" editor="numberspinner">Unit Cost</th> <th field="attr1" width="180" editor="text">Attribute</th> <th field="status" width="60" align="center" editor="{type:'checkbox',options:{on:'P',off:''}}">Status</th> <th field="action" width="80" align="center" formatter="formatAction">Action</th> </tr> </thead> </table>
我們分配numberspinner編輯器到 'unit cost' 字段中,當開始編輯一行時,用戶可以通過numberspinner編輯器來編輯數據。
下載EasyUI示例:
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自:慧都控件網