zoukankan      html  css  js  c++  java
  • Grouping Grid分组排序

    var xg = Ext.grid;

                var store = new Ext.data.GroupingStore({
                    proxy: new Ext.data.HttpProxy(
       {
           url: Bronze.Common.ajaxURL
       }),

                    remoteSort: false, //是否远程排序
                    remoteGroup:true,
                    reader: new Ext.data.JsonReader(
       {
           root: 'Rows',             //这两个属性对应后台的解析json格式
           totalProperty: 'Total',
           id: 'FID'
       }, [
       {
           name: 'Fid',
           mapping: 'FID', //对应数据库的列名
           type: 'string'
       },
       {
           name: 'FName',
           mapping: 'FName',
           type: 'string'
       },
       {
           name: 'TermName',
           mapping: 'TermName',
           type: 'string'
       },
                {
                    name: 'FCreateDate',
                    mapping: 'FCreateDate',
                    type: 'date'
                }]),
                    sortInfo: { field: 'TermName', direction: "DESC" },
                    groupField: 'TermName',
                    groupDir:'desc',//起作用的是这个属性,这个属性虽然可以使用,但却没有出现在官方使用说明文档中
                    baseParams: //传入的参数
       {
       classname: 'SubjectTScoreStat',
       methodname: 'GetTermExamsByClAndSub',
                classIds:"",
                subjectIds:""
    }
                });
                var renderInput = function (value, metadata, record, rowIndex, colIndex, store) {
                    metadata.attr = 'style="border:1px solid #6593cf;"';
                    return value || '';
                };
                var grid = new Ext.grid.EditorGridPanel({
                    store: store,
                    columns: [
                        { header: "TermName", 60, dataIndex: 'TermName' , hidden:true},
                        { header: "考试名称", 20, dataIndex: 'FName' },
                        { header: "开始名次", 20, sortable: true, dataIndex: 'start', editor: new Ext.form.NumberField({
                            allowBlank: true,
                            allowNegative: false,
                            selectOnFocus: true,
                            minValue: 1
                        }),
                            renderer: renderInput
                        },
                        { header: "结束名次", 20, sortable: true, dataIndex: 'end', editor: new Ext.form.NumberField({
                            allowBlank: true,
                            allowNegative: false,
                            selectOnFocus: true,
                            minValue: 1
                        }),
                            renderer: renderInput
                        }
                    ],
                    view: new Ext.grid.GroupingView({
                        showGroupName: false,
                        forceFit: true,
                        groupTextTpl: '{text} ({[values.rs.length]} {[values.rs.length > 1 ? "Items" : "Item"]})'
                    }),
                    frame: true,
                    250,
                    height: 550,
                    //collapsible: true,
                    //animCollapse: false,
                    //title: 'Grouping Example',
                    iconCls: 'icon-grid',
                    clicksToEdit: 1
                    //renderTo: document.body
                });
                store.load();
    //            grid.on('afteredit', afterEdit, this);

                var json = [];
                function afterEdit(e) {
              
                };
                grid.on('validateedit', function (e) {
               
                    if (e.field == "start" && e.record.data.end != null && e.record.data.end != "" && e.value!="") {
                        if (e.value <= e.record.data.end) {
                            return true;
                        }
                        else {
                            alert('开始名次不能高于结束名次!');
                            return false;

                        }
                    }
                    else if (e.field == "end" && e.record.data.start != null && e.record.data.start != "" && e.value != "") {
                        if (e.value >= e.record.data.start) {
                            return true;
                        }
                        else {
                            alert('开始名次不能高于结束名次!');
                            return false;

                        }
                    }
                    else
                    {
                        return true;
                    }

                });

                var comTermExam = new ComboBoxGrid({
                    editable: false,
                    name: 'FSubjectName',
                    fieldLabel: '考试',
                    displayField: 'FName',
                    valueField:'Fid',
                    //mode: 'local',
                    //                forceSelection: true,
                    triggerAction: 'all',
                    //emptyText: '--所有--',
                    //                selectOnFocus: true,
                    hiddenName: 'FSubjectId',
                    grid: grid,
                    'onSelect': function (record, index) {
                        if (this.fireEvent('beforeselect', this, record, index) !== false) {
    //                        this.setValue(record.data[this.valueField || this.displayField]);

                            //this.collapse();
                            this.fireEvent('select', this, record, index);
                        }
                    },
                    onViewClick: function (doFocus) {
    //                    var index = this.view.getSelectedIndexes()[0],
    //                    s = this.store,
    //                    r = s.getAt(index);
    //                    if (r) {
    //                        this.onSelect(r, index);
    //                    } else {
    //                        //this.collapse();
    //                    }
    //                    if (doFocus !== false) {
    //                        this.el.focus();
    //                    }
                    }
                });
                comTermExam.on('gridselected',
                    function () {
                       
                    }
                );

  • 相关阅读:
    js 检测浏览器
    js获取url参数
    js 使用Math函数取得数组最大最少值
    js 取一定范围内的整数
    遍历文件夹内所有文件
    'weinre' 不是内部或外部命令,也不是可运行的程序 或批处理文件。 解决方案
    解决图片缓存导致页面刷新无效果问题
    JAVA中的几种基本数据类型是什么,各自占用多少字节
    Mac终端git,svn提交代码步骤
    小程序分享链接功能
  • 原文地址:https://www.cnblogs.com/yellowsail/p/1893375.html
Copyright © 2011-2022 走看看