编辑子例程-jquery easyui edatagrid



好吧,从上周五开始,我就一直在为这个问题头疼,我想终于到了发帖寻求帮助的时候了。我认为我的代码已经很好地解决了,我认为事情应该能正常工作。

我有一个网格,在那里我编辑行,添加行,然后扩展行加载子网格(可编辑edatagrid)。我想简单地编辑和取消可编辑的子网格。但是,我还想从父行(api)获取传递给服务器页面的ID列以进行更新。

编辑和添加新行是可行的,在子行的可编辑网格中打开我想要的可编辑字段是可行的。但是,让子网格取消编辑、保存和使用iconCl将不起作用(此时已删除子网格的iconCl代码)。我没有包括所有的代码,只是与这里的问题相关的代码,所以还有一些其他缺少javascript的调用。如果有人想要那个代码,请大声喊,我会把它包括在内。

主电网

<section class="grid">     
  <table id="wells" class="easyui-datagrid" title=" " style="width:100%;height:500px"
        pagination="true" idField="api" fitColumns="true" url="getinfo.php"
        collapsible="true" singleSelect="true" toolbar="#tb" resizeHandle="both"
        autoRowHeight="true" nowrap="false" rownumbers="true" pageList="[10,25,50,100,5000]">
        <thead>
            <tr>
                <th data-options="field:'well_name', width:48" sortable="true">Name</th>
                <th data-options="field:'well_num',width:18" sortable="true">Num</th>
                <th data-options="field:'field',width:48" sortable="true">Field</th>
                <th data-options="field:'pad',width:36" sortable="true">Pad</th>
                <th data-options="field:'api',width:32" sortable="true">API</th>
                <th data-options="field:'legal_description',width:46" sortable="true">Legal</th>
                <th data-options="field:'county_state',width:40" sortable="true">County, State</th>
                <th data-options="field:'lease',width:33" sortable="true">Lease</th>
                <th data-options="field:'unit_ca_pa',width:57" sortable="true">Unit CA PA</th>
                <th data-options="field:'status',width:27">Status</th>
                <th data-options="field:'status_date',width:22">Updated</th>
                <th data-options="field:'wildlife_stips',width:75">Wildlife Stips</th>
                <th data-options="field:'notes',width:75">Notes</th>                                
            </tr>
        </thead>
  </table>

主网格工具栏

  <div id="tb" style="padding:3px"><span>Field:</span>
      <input id="field" style="line-height:22px;border:1px solid #ccc">
        <span>Pad:</span>
        <input id="pad" style="line-height:22px;border:1px solid #ccc">
        <span>API:</span>
        <input id="api" style="line-height:22px;border:1px solid #ccc">
        <a href="#" class="easyui-linkbutton" plain="true" onclick="doSearch()">Search</a>
        <a href="#" class="easyui-linkbutton" plain="true" onclick="doReset()">Reset</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="newWell()">New Well</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editWell()">Edit Well</a>
  </div>

可扩展的edatagrid段

    <script type="text/javascript">
        $('#wells').datagrid(
        {
            view: detailview,
            detailFormatter:function(index,row)
            { return '<div style="padding:2px"><table class="ddv"></table></div>'; },
                onExpandRow: function(index,row)
                {
                    var ddv = $(this).datagrid('getRowDetail',index).find('table.ddv');
                    ddv.edatagrid(
                    {
                        url:'geteditexpand.php?api='+row.api,
                        saveUrl:'updateeditwell.php?api='+row.api,
                        fitColumns:true,
                        singleSelect:true,
                        rownumbers:true,
                        loadMsg:'',
                        height:'auto',
                        columns:[[
                            {field:'location',title:'Location'},
                            {field:'NorthSouth',title:'N+S-',editor:'text'},
                            {field:'EastWest',title:'E+W-',editor:'text'},
                            {field:'latitude',title:'Latitude',editor:'text'},
                            {field:'longitude',title:'Longitude',editor:'text'},
                            {field:'lot',title:'Lot',editor:'text'},
                            {field:'tract',title:'Tract',editor:'text'},
                            {field: 'action', title: 'Action',
                                 formatter:function(value,row,index)
                                 {
                                    var s = '<a href="#" onclick="javascript:$(#wells).edatagrid(saveRow)">Save</a> ';
                                    var c = '<a href="#" onclick="javascript:$(#wells).edatagrid(cancelRow)">Cancel</a>';
                                    return s+c;
                                }
                            }
                        ]],
                        onResize:function()
                        { $('#wells').edatagrid('fixDetailRowHeight',index); },
                        onLoadSuccess:function()
                        {
                            setTimeout(function(){
                            $('#wells').edatagrid('fixDetailRowHeight',index);
                        },0);
                    }
                });
                $('#wells').datagrid('fixDetailRowHeight',index);
            }   
        });
    </script>

您没有更新URL,我不确定

url(源)saveUrl(NewRecord)

失踪updateUrl:'updatefile.php'

最新更新