解决方案 »

  1.   

    问lz歌问题,easyui国内买多少钱
      

  2.   

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>Row Editing DataGrid - jQuery EasyUI Demo</title>
    <link rel="stylesheet" type="text/css" href="../../themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="../../themes/icon.css">
    <link rel="stylesheet" type="text/css" href="../demo.css">
    <script type="text/javascript" src="../../jquery-1.8.0.min.js"></script>
    <script type="text/javascript" src="../../jquery.easyui.min.js"></script>
    </head>
    <body>
    <h2>Row Editing DataGrid</h2>
    <div class="demo-info">
    <div class="demo-tip icon-tip"></div>
    <div>Click the row to start editing.</div>
    </div>
    <div style="margin:10px 0;"></div>

    <table id="dg" class="easyui-datagrid" title="Row Editing DataGrid" style="width:700px;height:auto"
    data-options="
    iconCls: 'icon-edit',
    singleSelect: true,
    toolbar: '#tb',
    url: '../datagrid/datagrid_data1.json',
    onClickRow: onClickRow
    ">
    <thead>
    <tr>
    <th data-options="field:'itemid',width:80">Item ID</th>
    <th data-options="field:'productid',width:100,
    formatter:function(value,row){
    return row.productname;
    },
    editor:{
    type:'combobox',
    options:{
    valueField:'productid',
    textField:'productname',
    url:'../datagrid/products.json',
    required:true
    }
    }">Product</th>
    <th data-options="field:'listprice',width:80,align:'right',editor:{type:'numberbox',options:{precision:1}}">List Price</th>
    <th data-options="field:'unitcost',width:80,align:'right',editor:'numberbox'">Unit Cost</th>
    <th data-options="field:'attr1',width:250,editor:'text'">Attribute</th>
    <th data-options="field:'status',width:60,align:'center',editor:{type:'checkbox',options:{on:'P',off:''}}">Status</th>
    </tr>
    </thead>
    </table> <div id="tb" style="height:auto">
    <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="append()">Append</a>
    <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true" onclick="remove()">Remove</a>
    <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-save',plain:true" onclick="accept()">Accept</a>
    <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-undo',plain:true" onclick="reject()">Reject</a>
    <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" onclick="getChanges()">GetChanges</a>
    </div>

    <script type="text/javascript">
    var editIndex = undefined;
    function endEditing(){
    if (editIndex == undefined){return true}
    if ($('#dg').datagrid('validateRow', editIndex)){
    var ed = $('#dg').datagrid('getEditor', {index:editIndex,field:'productid'});
    var productname = $(ed.target).combobox('getText');
    $('#dg').datagrid('getRows')[editIndex]['productname'] = productname;
    $('#dg').datagrid('endEdit', editIndex);
    editIndex = undefined;
    return true;
    } else {
    return false;
    }
    }
    function onClickRow(index){
    if (editIndex != index){
    if (endEditing()){
    $('#dg').datagrid('selectRow', index)
    .datagrid('beginEdit', index);
    editIndex = index;
    } else {
    $('#dg').datagrid('selectRow', editIndex);
    }
    }
    }
    function append(){
    if (endEditing()){
    $('#dg').datagrid('appendRow',{status:'P'});
    editIndex = $('#dg').datagrid('getRows').length-1;
    $('#dg').datagrid('selectRow', editIndex)
    .datagrid('beginEdit', editIndex);
    }
    }
    function remove(){
    if (editIndex == undefined){return}
    $('#dg').datagrid('cancelEdit', editIndex)
    .datagrid('deleteRow', editIndex);
    editIndex = undefined;
    }
    function accept(){
    if (endEditing()){
    $('#dg').datagrid('acceptChanges');
    }
    }
    function reject(){
    $('#dg').datagrid('rejectChanges');
    editIndex = undefined;
    }
    function getChanges(){
    var rows = $('#dg').datagrid('getChanges');
    alert(rows.length+' rows are changed!');
    }
    </script>
    </body>
    </html>
      

  3.   

    你的应该是没运行这句:$('#dg').datagrid('endEdit', editIndex);
      

  4.   


    首先谢谢了,但是 在一个table里面是可以的,我要放置详情页面怎么处理呢
      

  5.   

                                onDblClickCell:function(index, field, value){
                                    if(index != 0) { ddv.datagrid("endEdit",lastIndex);}
                                    ddv.datagrid('beginEdit',index);
    //                                var ed = ddv.datagrid('getEditor',{
    //                                    index:index,
    //                                    field:field
    //                                });                                lastIndex = index;
                                   
                                },
    EndEdit之后前面的+也没了,刚才你给我的例子我也尝试过了一样的
      

  6.   

    这个编辑或加入新行你不能页面加入就完了 ,你的用ajax 修改库 ,把数据持久化了 。
    每次修改完一行数据,要刷新当前的表格。
      

  7.   

    呵呵,我看你们是偷着用啊,我看官方文档收费的,449美元。只是不知道国内多少。非也非也。
    449美元那个买的是服务:
        Source Code
        Up to 5 developers to use at a time
        No limitations on the number of projects/sites
        Use the software for any period of time you need
        Tech support on the product within 1 year
        Free upgrades for a period of 1 year
    ===我们不需要以上服务,当然是免费,有官网证言:
    GPL Edition
    The GPL Edition is available under GPL License, you can use it in any GPL-licensed projects. Download jQuery EasyUI under GPL license:
    Commercial Edition
    The Commercial Edition is also available under Commercial License, you can use it in a non-GPL/proprietary project. 
      

  8.   

    嗯,看见GPL就好了,以前一直用extjs,看来可以考虑一下easyui了,就怕以后的版本又收费了