本人使用livegrid上的代码:Ext.require([
    'Ext.grid.*',
    'Ext.data.*',
    'Ext.util.*',
    'Ext.grid.PagingScroller',
'Ext.ux.RowExpander',
    'Ext.selection.CheckboxModel'

]);Ext.onReady(function(){
    Ext.define('ForumThread', {
        extend: 'Ext.data.Model',
        fields: [
            'title', 'forumtitle', 'forumid', 'author',
            {name: 'replycount', type: 'int'},
            {name: 'lastpost', mapping: 'lastpost', type: 'date', dateFormat: 'timestamp'},
            'lastposter', 'excerpt', 'threadid'
        ],
        idProperty: 'threadid'
    });    // create the Data Store
 var sm = Ext.create('Ext.selection.CheckboxModel');

    var store = Ext.create('Ext.data.Store', {
        id: 'store',
        pageSize: 200,
        model: 'ForumThread',
        remoteSort: true,
        // allow the grid to interact with the paging scroller by buffering
        buffered: true,
        proxy: {
            // load using script tags for cross domain, if the data in on the same domain as
            // this page, an HttpProxy would be better
            type: 'jsonp',
            url: 'http://www.sencha.com/forum/remote_topics/index.php',
            extraParams: {
                total: 50000
            },
            reader: {
                root: 'topics',
                totalProperty: 'totalCount'
            },
            // sends single sort as multi parameter
            simpleSortMode: true
        },
        sorters: [{
            property: 'lastpost',
            direction: 'DESC'
        }]
    });    function renderTopic(value, p, record) {
        return Ext.String.format(
            '<a href="http://sencha.com/forum/showthread.php?t={2}" target="_blank">{0}</a>',
            value,
            record.data.forumtitle,
            record.getId(),
            record.data.forumid
        );
    } var sm = Ext.create('Ext.selection.CheckboxModel');
 
    var grid = Ext.create('Ext.grid.Panel', {
        width: 700,
        height: 500,
        title: 'checkbox',
        store: store,
selModel: sm,
frame: true,
        verticalScrollerType: 'paginggridscroller',
        loadMask: true,
        disableSelection: false,
        invalidateScrollerOnRefresh: false,
        viewConfig: {
        trackOver: false
        },
        // grid columns
        columns:[{
            id: 'topic',
            text: "Topic",
            dataIndex: 'title',
            flex: 1,
            renderer: renderTopic,
            sortable: false
        },{
            text: "Author",
            dataIndex: 'author',
            width: 100,
            hidden: true,
            sortable: true
        },{
            text: "Replies",
            dataIndex: 'replycount',
            align: 'center',
            width: 70,
            sortable: false
        },{
            id: 'last',
            text: "Last Post",
            dataIndex: 'lastpost',
            width: 130,
            renderer: Ext.util.Format.dateRenderer('n/j/Y g:i A'),
            sortable: true
        }],
        renderTo: 'grid-example'
    });
   // trigger the data store load
    store.guaranteeRange(0, 199);

解决方案 »

  1.   

    var records = grid.getSelectionModel().getSelection();
    获取到选中行
      

  2.   

    function chkVal(){
    var selChk;
    rec = Ext.getCmp('xxgrid').getSelectionModel().getSelection();
    for (var i = 0; i < rec.length; i++) {
             selChk += rec[i].get("topic")
             if (i < rec.length - 1) {
                 selChk = selChk + ",";
                    }
    }
    alert(selChk);
    }rec[i].get("topic")这里不是写列的id吗?怎么取出来都是undefined
      

  3.   

    columns:[{
                id: 'topic',
                text: "Topic",
                dataIndex: 'title',
                flex: 1,
                renderer: renderTopic,
                sortable: false
            },{
                text: "Author",
                dataIndex: 'author',
                width: 100,
                hidden: true,
                sortable: true
            },{
                text: "Replies",
                dataIndex: 'replycount',
                align: 'center',
                width: 70,
                sortable: false
            },{
                id: 'last',
                text: "Last Post",
                dataIndex: 'lastpost',
                width: 130,
                renderer: Ext.util.Format.dateRenderer('n/j/Y g:i A'),
                sortable: true
            }],
    在第一列加上 sm,再是你后面的东西
      

  4.   

    var data = grid.getSelectionModel().getSelected().get("youChk"); 
    选中设置checked:true
      

  5.   

    什么意思?求详解..初接触ext
      

  6.   

    columns:[
    sm,{
     id: 'topic',
     text: "Topic",
     dataIndex: 'title',
     flex: 1,
     renderer: renderTopic,
     sortable: false
     },{
     text: "Author",
     dataIndex: 'author',
     width: 100,
     hidden:……
      

  7.   

    加了sm,grid就不能生成,还要定义什么吗?
      

  8.   

    哪能这么写啊?你原来这么写就对var grid = Ext.create('Ext.grid.Panel', {
            width: 700,
            height: 500,
            title: 'checkbox',
            store: store,
            selModel: sm,
            .
            .
            .
      

  9.   

    原来不是get('id')是get('dataIndex')...另外怎么赋值?求解答