簡體   English   中英

EXTJS:如何判斷datagrid中的header復選框是否被點擊

[英]EXTJS: How to determine if header checkbox in datagrid has been clicked

我想知道是否單擊了 headerCheckbox(全選)。 我在這里從 sencha fiddle 得到了這個例子:

https://fiddle.sencha.com/#fiddle/1gvv&view/editor

`Ext.application({ name: 'Fiddle', launch: function() {

    // Define our data model
    Ext.define('MyModel', {
        extend: 'Ext.data.Model',
        fields: ['firstField', 'secondField']
    });

    // Generate mock data
    var data = [{
        "firstField": "one",
        "secondField": "1"
    }, {
        "firstField": "two",
        "secondField": "2"
    }, {
        "firstField": "three",
        "secondField": "3"
    }, {
        "firstField": "four",
        "secondField": "4"
    }, {
        "firstField": "five",
        "secondField": "5"
    }];

    // create the Data Store
    var store = Ext.create('Ext.data.Store', {
        // destroy the store if the grid is destroyed
        autoDestroy: true,
        model: 'MyModel',
        proxy: {
            type: 'memory'
        },
        data: data
    });

    var sm = new Ext.selection.CheckboxModel({
        checkOnly: true,
        listeners: {
           selectionchange: 'onSelectionChange'
        }
    });

    var grid = Ext.create('Ext.grid.Panel', {
        store: store,
        selModel: sm,
        columns: [{
            header: 'firstField',
            dataIndex: 'firstField',
            flex: 1
        }, {
            header: 'secondField',
            dataIndex: 'secondField',
            flex: 1
        }],
        tbar: [{
            xtype: 'textfield',
            fieldLabel: 'firstField',
            itemId: 'mytextfield'
        }, {
            text: 'Select',
            handler: function() {
               // try to find the record having the firstField field as the entered one
                var selectedRecord = grid.getStore().findRecord('firstField', grid.down('#mytextfield').getValue()); 
               if (selectedRecord) {
                    grid.getSelectionModel().select(selectedRecord);
                }
            }
        }]
    });
    new Ext.window.Window({
        width: 700,
        height: 400,
        items: grid,
        layout: 'fit',
        closable: false
    }).show();


}

});`

我已經放置了onSelectionChange偵聽器,但是要在其中放置什么才能知道 select 是否全部被單擊?

感謝您的幫助。

我今天在搜索完全相同的東西時遇到了你的問題。

經過一些嘗試,這就是我得到的 -

煎茶小提琴

本質上,您需要獲取檢查列,然后allChecked checkcolumn是否設置為true

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM