ExtJs中的GridPanel取每一行其中一个字段的值,急!!!!

何必为难 2013-01-26 09:42:27

DataTable dt = DbHelperSQL.ExcuteQuery(sql);
for (int i = 0; i < dt.Rows.Count; i++)
{
string id=dt.Rows[i]["ID"].ToString();
}

我的意思就是从GridPane中取第i行的ID值.Rows[i]["ID"]

for (var i = 0; i < bGrid.getStrore().getCount(); i++) {
string id=dt.Rows[i]["ID"].ToString();//这里的意思就是取bGrid的每行的ID字段的值,具体写法不知道
}

GridPanel中的第i行的ID字段怎么表示啊

麻烦各位帮忙!!!
...全文
271 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
胡萝卜zpc 2013-06-23
  • 打赏
  • 举报
回复
引用 1 楼 orange_shuiguo 的回复:

bGrid.getStrore().getAt(i).get('ID');
应该是getStore()
何必为难 2013-01-26
  • 打赏
  • 举报
回复
引用 2 楼 licip 的回复:
引用 1 楼 orange_shuiguo 的回复: JavaScript code?1bGrid.getStrore().getAt(i).get('ID');说这种方法
是这种么?

 for (var i = 0; i < bGrid.getStrore().getCount(); i++) {

        /*切换列表 EXT*/
        var MLcm = new Ext.grid.ColumnModel([{
            header: "代码",
            sortable: true,
            width: 20,
            dataIndex: 'ID'
        }, {
            header: "名称",
            sortable: true,
            width: 20,
            dataIndex: 'comp'
        }, {
            header: "单位",
            sortable: true,
            width: 20,
            dataIndex: 'posi'
        }, {
            header: "规格",
            sortable: true,
            width: 20,
            dataIndex: 'Eg'
        }, {
            header: "材质",
            sortable: true,
            width: 20,
            dataIndex: 'photo'
        }, {
            header: "颜色",
            sortable: true,
            width: 20,
            dataIndex: 'HouxuanID'
        }, {
            header: "图片",
            sortable: true,
            width: 20,
            dataIndex: 'photo',
            renderer: function (v) {
                return "<input id='show' type=image src='photo' title='show' style='width:20px;height:20px'  onmousemove=\"Imgmousemove(this)\"  onmouseout=\"Imgmouseout()\"  />";
            }
        }]);
        MLStore = new Ext.data.Store({
            proxy: new Ext.data.HttpProxy({
                method: 'POST',
                url: '../../../Hou.mvc/GetHouxuan',
                data: {st:bGrid.getStrore().getAt(i).get('ID')}
            }),
            reader: new Ext.data.JsonReader({
                totalProperty: 'totalCount',
                root: 'root',
                id: 'ID',
                fields: [{
                    name: 'ID',
                    type: 'string'
                }, {
                    name: 'comp',
                    type: 'string'
                }, {
                    name: 'posi',
                    type: 'string'
                }, {
                    name: 'Eg',
                    type: 'string'
                }, {
                    name: 'photo',
                    type: 'string'
                }, {
                    name: 'HouxuanID',
                    type: 'string'
                }, {
                    name: 'photo',
                    type: 'string'
                }]
            })
        });
        bBbar = new Ext.PagingToolbar({
            store: MLStore,
            pageSize: pageSize,
            displayInfo: true,
            beforePageText: '第',
            afterPageText: '页- 共{0}页',
            displayMsg: '显示 {0} - {1}条 / 共{2}条',
            emptyMsg: "暂无数据"
        });

        qGrid = new Ext.grid.GridPanel({
            renderTo: 'tLiebiao',
            autoWidth: true,
            autoHeight: true,
            store: MLStore,
            autoScroll: true,
            cm: MLcm,
            stripeRows: true,
            loadMask: {
                msg: '正在加载数据,请稍侯……'
            },
            trackMouseOver: true,
            viewConfig: {
                forceFit: true,
                enableRowBody: true,
                showPreview: true,
                getRowClass: function (record, rowIndex, p, store) {
                    return 'x-grid3-row-collapsed';
                }
            },
            bbar: bBbar
        });
        MLStore.load({ params: { start: 0, limit: pageSize} });
        qGrid.hide();
        /*切换列表 EXT Grid  end*/




        bBbar = new Ext.PagingToolbar({
            store: MLStore,
            pageSize: pageSize,
            displayInfo: true,
            beforePageText: '第',
            afterPageText: '页- 共{0}页',
            displayMsg: '显示 {0} - {1}条 / 共{2}条',
            emptyMsg: "暂无数据"
        });


        var xd = Ext.data;
        var tpl = new Ext.XTemplate(
		'<tpl for="." >',
            '<div class="thumb-wrap" id="{ID}">',
		    '<div class="thumb"><img WIDTH=165px  HEIGHT=140px src="{photo}" title="{ID}"></div>',
		    '<span class="x-editable">{shortName}</span></div>',
        '</tpl>',
        '<div class="x-clear"></div>'
	);

        panel = new Ext.Panel({
            id: 'images-view',
            frame: true,
            autoWidth: true,
            autoHeight: true,
            collapsible: true,
            layout: 'fit',
            title: '图片列表',

            items: new Ext.DataView({
                store: MLStore,
                tpl: tpl,
                autoHeight: true,
                multiSelect: true,
                overClass: 'x-view-over',
                itemSelector: 'div.thumb-wrap',
                emptyText: '无数据',
                prepareData: function (data) {
                    data.shortName = Ext.util.Format.ellipsis(data.C_name + data.E_name, 30);
                    return data;
                },
                listeners: {
                    'click': function (dataview, index, node, e) {
                        var record = dataview.getStore().getAt(index);
                        wOutWin(record.get('ID'));
                        //do sth...  
                    },
                    scope: this
                }

            }),
            bbar: bBbar

        });
        panel.render(document.body);
    }
做循环的时候总是报错:对象不支持此属性或方法!不知道怎么回事
licip 2013-01-26
  • 打赏
  • 举报
回复
引用 1 楼 orange_shuiguo 的回复:
JavaScript code?1bGrid.getStrore().getAt(i).get('ID');
说这种方法
  • 打赏
  • 举报
回复

bGrid.getStrore().getAt(i).get('ID');

87,917

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧