zoukankan      html  css  js  c++  java
  • Easy ui Datagrid(下拉、复选、只输入数字、文本) 追加、删除、更改

        <tr>
                    <th data-options="field:'itemid',80">Item ID</th>
                    <th data-options="field:'productid',100,formatter:productFormatter,
                            editor:{
                                type:'combobox',
                                options:{
                                    valueField:'productid',
                                    textField:'name',
                                    data:products,
                                    required:true
                                }
                            }">Product</th>
                    <th data-options="field:'listprice',80,align:'right',editor:{type:'numberbox',options:{precision:1}}">List Price</th>
                    <th data-options="field:'unitcost',80,align:'right',editor:'numberbox'">Unit Cost</th>
                    <th data-options="field:'attr1',250,editor:'text'">Attribute</th>
                    <th data-options="field:'status',60,align:'center',editor:{type:'checkbox',options:{on:'P',off:''}}">Status</th>
                </tr>
    $(function(){
                var lastIndex;
                $('#tt').datagrid({
                    toolbar:[{
                        text:'append',
                        iconCls:'icon-add',
                        handler:function(){
                            $('#tt').datagrid('endEdit', lastIndex);
                            $('#tt').datagrid('appendRow',{
                                itemid:'',
                                productid:'',
                                listprice:'',
                                unitprice:'',
                                attr1:'',
                                status:'P'
                            });
                            lastIndex = $('#tt').datagrid('getRows').length-1;
                            $('#tt').datagrid('selectRow', lastIndex);
                            $('#tt').datagrid('beginEdit', lastIndex);
                        }
                    },'-',{
                        text:'delete',
                        iconCls:'icon-remove',
                        handler:function(){
                            var row = $('#tt').datagrid('getSelected');
                            if (row){
                                var index = $('#tt').datagrid('getRowIndex', row);
                                $('#tt').datagrid('deleteRow', index);
                            }
                        }
                    },'-',{
                        text:'GetChanges',
                        iconCls:'icon-search',
                        handler:function(){
                            var rows = $('#tt').datagrid('getChanges');
                            alert('changed rows: ' + rows.length + ' lines');
                        }
                    }],
                    onBeforeLoad:function(){
                        $(this).datagrid('rejectChanges');
                    },
                    onClickRow:function(rowIndex){
                        if (lastIndex != rowIndex){
                            $('#tt').datagrid('endEdit', lastIndex);
                            $('#tt').datagrid('beginEdit', rowIndex);
                        }
                        lastIndex = rowIndex;
                    }
                });
            });
  • 相关阅读:
    inkscape
    关于英语写作词源方面的。。
    ubuntu上配tensorflow
    腾讯面试指南
    使用traceview进行Android性能测试(转)
    Android CTS 测试总结【转】
    JAVA和C++区别
    接口继承
    vim实现全选功能
    C++异常机制的实现方式和开销分析
  • 原文地址:https://www.cnblogs.com/yhyjy/p/3011775.html
Copyright © 2011-2022 走看看