[模板]对Dgrid表格进行模糊搜索(自用)

html文件,dgrid模糊搜索.html

<div>
	<input data-dojo-attach-point="input" type="text" value="" />
	<div data-dojo-attach-point="grid"></div>
</div>
js文件,dgrid模糊搜索.js
define([
    "dojo/dom",
    "dojo/_base/declare",
    "dojo/store/Memory",
    "dojo/store/Observable",
    
    "dgrid/Keyboard",
    "dgrid/OnDemandGrid",
    "dgrid/Selection",
    "dgrid/selector",
    "dgrid/extensions/Pagination", 
    "dgrid/extensions/ColumnResizer",
    
    "dijit/form/Button",
    "dijit/_TemplatedMixin",
    "dijit/_WidgetBase",
    "dijit/_WidgetsInTemplateMixin",
    
    "dojo/text!html文件路径/dgrid模糊搜索.html"
    "dojo/domReady!"
], function(dom, declare, Memory, Observable,
    Keyboard, OnDemandGrid, Selection, selector, Pagination, ColumnResizer,
    Button, _TemplatedMixin, _WidgetBase, _WidgetsInTemplateMixin, template) {
    
    return declare([_WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin], {
        templateString : template,
        
        data: [{_index: 1, userName: "haha"}, {_index: 2, userName: "chanhaha"}],
        
        constructor : function() {
            this.inherited(arguments);
        },
        
        postCreate : function() {
            this.inherited(arguments);
            this.main();
        },
        
        main: function() {
            this._setGrid(this.data);
        },
        
        _setGrid : function(data) {
            var renderCell = function(object, data, cell) {
                new Button({
                    label: "renderCell",
                    onClick: function() {
                        
                    }
                }, cell.appendChild(document.createElement("div")));
            };
            var layout = {
                col1 : selector({resizable: false, width: 40}),
                name : {label: "用户名", resizable: false},
                todo : {label: "操作", renderCell: renderCell, resizable: false, width: 210}
            };
            this._store = new Memory({data : data});
            this._store = new Observable(this._store);
            this._grid = new (declare([OnDemandGrid, Selection, Keyboard, Pagination, ColumnResizer]))({
                columns : layout,
                store : this._store,
                allowSelectAll: true,
                style : "",
                selectionMode : "toggle",
                pagingLinks : 2,
                rowsPerPage : 10,
                pagingTextBox : true,
                firstLastArrows : true,
                loadingMessage : "数据加载中...",
                noDataMessage : "暂无数据。"
            }, this.grid);
            this._grid.startup();
            
            //调用模糊搜索功能。
            commom.onQuery(this.input, this._grid, data);
        }
        
    });
    
});
commom.onQuery方法在这里: http://blog.csdn.net/chanhaha/article/details/40343469

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值