ext.net 开发学习——GridView 操作(七)

细节决定成败

把遇到的一些细节上面的问题 总结下, 虽是小问题,但往往 就是小问题 会阻止你前进的步伐……

壹:GridView 列锁定

一、前台代码实现:

 <ext:GridPanel ID="GridPanel1" TrackMouseOver="true" StripeRows="true" runat="server"
Border="false" Title="人员信息" AutoScroll="true">
<Store>
<ext:Store ID="Store1" runat="server" OnRefreshData="MyData_Refresh">
<Reader>
<ext:JsonReader>
<Fields>
</Fields>
</ext:JsonReader>
</Reader>
</ext:Store>
</Store>
<SelectionModel>
<ext:RowSelectionModel ID="RowSelectionModel1" runat="server" SingleSelect="true" />
</SelectionModel>
<LoadMask ShowMask="true" />
<BottomBar>
<ext:PagingToolbar ID="PagingToolbar1" runat="server" PageSize="30" StoreID="Store1">
</ext:PagingToolbar>
</BottomBar>
<ColumnModel>
<Columns>
</Columns>
</ColumnModel>
<Listeners>
<DblClick Handler="addTab('idEmployeeInfo', 'EmployeeDetail.aspx','员工明细');" />
</Listeners>
<View>
<ext:LockingGridView ID="LockingGridView1" runat="server">
</ext:LockingGridView>
</View>
</ext:GridPanel>



二、后台代码实现:

                Column   col = new Column(); 
col.Header = fieldTable.Rows[i]["FieldCaption"].ToString();
string index = fieldTable.Rows[i]["FieldAlias"].ToString();
col.DataIndex = index;
if (index == "ProNo" || index == "ItemNo" || index == "CustItemNo" || index == "Item_C_Name")
col.Locked = true;

col.Width = Int32.Parse(string.IsNullOrEmpty(fieldTable.Rows[i]["ColWidth"].ToString()) ? "80" : fieldTable.Rows[i]["ColWidth"].ToString());
if (fieldTable.Rows[i]["ControlType"].ToString().Contains("Combobox"))
col.Renderer = new Renderer() { Fn = "rendererMeterTypeCombobox" };
col.Editor.Add(GetFiledControl(fieldTable.Rows[i]));
base.ColumnModel.Columns.Add(col);

别忘了给你的GridView添加这个属性    base.View.Add(new LockingGridView());//列锁定属性

效果:

ext.net 开发学习——GridView 操作(七)_第1张图片

贰:GridView日期格式

Ext.Net默认日期显示格式是英文的 “Thu Nov 3 00:00:00 UTC+0800 2011” 第一感觉是直接格式化转化。有属性DateFormat 但是设置了还是不管用。此时注意:不要被Ext的Column忽悠了,它还有一个DateColumn : DateColumn dtCol = new DateColumn(); dtCol.Format = "yyyy-MM-dd"; 即可

ext.net 开发学习——GridView 操作(七)_第2张图片

 

处理下效果:

ext.net 开发学习——GridView 操作(七)_第3张图片

 

叁:行号

见图说话

ext.net 开发学习——GridView 操作(七)_第4张图片

需要在红框左边添加 “行号”

GridView.ColumnModel.Columns.Add(new RowNumbererColumn());

效果:

ext.net 开发学习——GridView 操作(七)_第5张图片

 

反之  删除就不显示

 

 2011-11-05

肆:列统计

 

ext.net 开发学习——GridView 操作(七)_第6张图片

      //列统计计算
function GridSum() {
var src = storehide.getValue();//查找那些列需要进行统计 eg:“txtTotProdAmt,sum,NTSaleAmt|txtTotVAT,sum,VAT"
var str = src.split('|');
for (var i = 0; i < str.length; i++) {
var strs = str[i].split(',');
var sum = 0;
store2.each(function(record) {//Grid源Store ID:store2
if (strs[1] == "sum") {
if (Number(record.get(strs[2])) > 0)
sum += Number(record.get(strs[2]));
}
});
Ext.getCmp(strs[0]).setValue(sum);
}
}

HTML

    <ext:Store runat="server" ID="store2" AutoLoad="true" OnRefreshData="stGrid_Refresh"
ShowWarningOnFailure
="false" SkipIdForNewRecords="false" RefreshAfterSaving="Always"
OnBeforeStoreChanged
="stGrid_BeforeChanged">
<Reader>
<ext:JsonReader>
<Fields>
<ext:RecordField Name="ProNo" Type="String"/>
<ext:RecordField Name="ItemNo" Type="String"/>
<ext:RecordField Name="CustItemNo" Type="String"/>
<ext:RecordField Name="Item_C_Name" Type="String"/>
<ext:RecordField Name="Item_C_Spec" Type="String"/>
<ext:RecordField Name="BUnit" Type="String"/>
<ext:RecordField Name="CBUnit" Type="String"/>
<ext:RecordField Name="UTRM" Type="String"/>
<ext:RecordField Name="UTR" Type="String"/>
<ext:RecordField Name="Unit" Type="String"/>
<ext:RecordField Name="CUnit" Type="String"/>
<ext:RecordField Name="Brand" Type="String"/>
<ext:RecordField Name="Color" Type="String"/>
<ext:RecordField Name="Material" Type="String"/>
<ext:RecordField Name="PTFID" Type="String"/>
<ext:RecordField Name="ManufNote" Type="String"/>
<ext:RecordField Name="Packing" Type="String"/>
<ext:RecordField Name="AddFld1" Type="String"/>
<ext:RecordField Name="AddFld2" Type="String"/>
<ext:RecordField Name="AddFld3" Type="String"/>
<ext:RecordField Name="AddFld4" Type="String"/>
<ext:RecordField Name="AddFld5" Type="String"/>
<ext:RecordField Name="AddFld6" Type="String"/>
<ext:RecordField Name="AddFld7" Type="String"/>
<ext:RecordField Name="AddFld8" Type="String"/>
<ext:RecordField Name="AddFld9" Type="String"/>
<ext:RecordField Name="AddFld10" Type="String"/>
<ext:RecordField Name="AddFld11" Type="String"/>
<ext:RecordField Name="AddFld12" Type="String"/>
<ext:RecordField Name="AddFld13" Type="String"/>
<ext:RecordField Name="AddFld14" Type="String"/>
<ext:RecordField Name="AddFld15" Type="String"/>
<ext:RecordField Name="AddFld16" Type="String"/>
<ext:RecordField Name="AddFld17" Type="String"/>
<ext:RecordField Name="AddFld18" Type="String"/>
<ext:RecordField Name="AddFld19" Type="String"/>
<ext:RecordField Name="AddFld20" Type="String"/>
<ext:RecordField Name="AddFld21" Type="String"/>
<ext:RecordField Name="AddFld22" Type="String"/>
<ext:RecordField Name="AddFld23" Type="String"/>
<ext:RecordField Name="AddFld24" Type="String"/>
<ext:RecordField Name="AddFld25" Type="String"/>
<ext:RecordField Name="BSaleQty" Type="Float"/>
<ext:RecordField Name="BSalePrice" Type="Float"/>
<ext:RecordField Name="SaleQty" Type="Float"/>
<ext:RecordField Name="OrgSalePrice" Type="Float"/>
<ext:RecordField Name="OffRT" Type="Float"/>
<ext:RecordField Name="OffAmt" Type="Float"/>
<ext:RecordField Name="SalePrice" Type="Float"/>
<ext:RecordField Name="SaleAmt" Type="Float"/>
<ext:RecordField Name="VATRT" Type="Float"/>
<ext:RecordField Name="VAT" Type="Float"/>
<ext:RecordField Name="NTSalePrice" Type="Float"/>
<ext:RecordField Name="NTSaleAmt" Type="Float"/>
</Fields>
</ext:JsonReader>
</Reader>
<Listeners>
<AfterRender Handler="GridSum();"/>
<Update Handler="GridSum();"/>
</Listeners>
</ext:Store>



 

 

 

伍:行统计

 

ext.net 开发学习——GridView 操作(七)_第7张图片

源码:

var afterEdit = function(e) {
var hid = hidRow2.getValue();
var strList = hid.split('|');
var strs;
var str;
var varRecord;
var varSelected;
var index;
var sum;
varRecord = gp2.getSelectionModel().getSelected();//gp2: Grid ID
index = store2.indexOf(varRecord); //获取选中了那一行 store2 :Grid数据源ID
if (index < 0)
return;
for (var i = 0; i < strList.length; i++) {
strs = strList[i].split(',');
if (strs[0].indexOf("["+e.field+"]") == -1)
continue;
if (strs.length < 2)
return;
str = strs[2].split('#'); //strs[] = [NTSaleAmt]+[VAT],SaleAmt,NTSaleAmt#VAT
for (var j = 0; j < str.length; j++) {//循环替换
varSelected = store2.getAt(index).get(str[j]); //取指定的值
strs[0] = strs[0].replace('[' + str[j] + ']', varSelected).replace(str[j], varSelected);
}
store2.getAt(index).set(strs[1], eval(strs[0])); //给指定赋值 strs[] = [NTSaleAmt]+[VAT],SaleAmt,NTSaleAmt#VAT
}
};

注意:

事件要给到Grid 不是Store

GridPanel.Listeners.AfterEdit.Fn = "afterEdit";

陆:单击取行值

 

ext.net 开发学习——GridView 操作(七)_第8张图片

 

源码:

  

    <script language="javascript" type="text/javascript">
function details() {
var gsm = gpList.getSelectionModel(); //gpList:GridPanel ID
var rows = gsm.getSelections();
if (rows.length > 0) {
for (var i = 0; i < rows.length; i++) {
var row = rows[i];
var data = row.get('ScNo');//ScNo 要取值的列名
alert(data);
}
}
}
</script>

 

柒:One to Many

需求效果:见图

ext.net 开发学习——GridView 操作(七)_第9张图片

                    

源码:

方案一:

给上面主GridPanel 添加 属性

 <Listeners>
<Click Fn="details" />
</Listeners> 

<SelectionModel>
<ext:RowSelectionModel ID="RowSelectionModel2" runat="server" SingleSelect="true">

</ext:RowSelectionModel>
</SelectionModel>

这个不可缺少

JS代码: 

    <script language="javascript" type="text/javascript">
        //GridPanel 加载 方案一
        function details() {
            var gsm = gpList.getSelectionModel(); //gpList:GridPanel ID
            var rows = gsm.getSelections();
            if (rows.length > 0) {
                for (var i = 0; i < rows.length; i++) {
                    var row = rows[i];
                    var data = row.get('ScNo'); //ScNo 要取值的列名
                    Ext.net.DirectMethods.GetInfosByID(data);
                }
            }
        }
    </script>

  

 

CS: 

        #region  GridPanel 加载 方案一
        [DirectMethod]
        public void GetInfosByID(string strID)
        {
            if (string.IsNullOrEmpty(strID))
                return;
            DataRow[] itemPanelList = structTabPageTable.Select("TreeLevel=2 AND StrucLevel<3");
            for (int i = 0; i < itemPanelList.Length; i++)
            {
                DataTable mould = MouldDao.GetMouldTables(structStr, itemPanelList[i]["SQLNo"].ToString());
                DataTable field;
                string index = string.Empty;
                if (itemPanelList[i]["IsStruc"].ToString().ToLower() == "true")
                {
                    index = itemPanelList[i]["SQLNo"].ToString();
                    field = MouldDao.GetMouldFiledsOrderByOrderNo(structStr, index);
                    dataCommand = MouldDao.GetDataCommand(mould, field);
                    dataCommand.Append(" WHERE  ScNo='" + strID + "'");
                    DataTable source = MouldDao.GetDataSource(dataCommand.ToString());
                    if (i == 2)
                    {
                        storeGoods.DataSource = source;
                        storeGoods.DataBind();
                    }

                    if (i == 4)
                    {
                        storePayments.DataSource = source;
                        storePayments.DataBind();
                    }
                    if (i == 5)
                    {
                        storeRecord.DataSource = source;
                        storeRecord.DataBind();
                    }
                    if (i == 6)
                    {
                        storeDomestic.DataSource = source;
                        storeDomestic.DataBind();
                    }
                }
            }
        } 
        #endregion

  

方案二:

根据在线DEMO 

前台代码

 <form id="form1" runat="server">
    <ext:ResourceManager ID="RMEmployeeInfos" runat="server" />
    <div>
        <ext:Store runat="server" ID="storeDomestic" AutoLoad="true" OnRefreshData="stGrid_Refresh"
            ShowWarningOnFailure="false" SkipIdForNewRecords="false" RefreshAfterSaving="Always"
            OnBeforeStoreChanged="stGrid_BeforeChanged">
            <Reader>
                <ext:JsonReader IDProperty="ScNo">
                    <Fields>
                        <ext:RecordField Name="ScNo" />
                        <ext:RecordField Name="CustID" Type="String" />
                        <ext:RecordField Name="BriefName" Type="String" />
                        <ext:RecordField Name="Item_C_Name" Type="String" />
                        <ext:RecordField Name="CreateDate" Type="Date" />
                        <ext:RecordField Name="SMTyp" Type="String" />
                        <ext:RecordField Name="CustPONo" Type="String" />
                        <ext:RecordField Name="Memo" Type="String" />
                        <ext:RecordField Name="OwnerID" Type="String" />
                        <ext:RecordField Name="OwnerNam" Type="String" />
                        <ext:RecordField Name="KeyInID" Type="String" />
                        <ext:RecordField Name="keyInName" Type="String" />
                        <ext:RecordField Name="KeyInDate" Type="Date" />
                        <ext:RecordField Name="keyInTime" Type="Date" />
                        <ext:RecordField Name="LastEditMan" Type="String" />
                        <ext:RecordField Name="LastEditDate" Type="Date" />
                        <ext:RecordField Name="AuditState" Type="String" />
                        <ext:RecordField Name="IsDeleted" Type="String" />
                        <ext:RecordField Name="SaleID" Type="String" />
                        <ext:RecordField Name="SaleName" Type="String" />
                        <ext:RecordField Name="DeptID" Type="String" />
                        <ext:RecordField Name="DeptName" Type="String" />
                        <ext:RecordField Name="CUR" Type="String" />
                        <ext:RecordField Name="RMBEXR" Type="String" />
                        <ext:RecordField Name="USEXR" Type="String" />
                        <ext:RecordField Name="TotProdAmt" Type="String" />
                        <ext:RecordField Name="TotAddFee" Type="String" />
                        <ext:RecordField Name="TotDeductFee" Type="String" />
                        <ext:RecordField Name="TotVAT" Type="String" />
                        <ext:RecordField Name="PaymentMode" Type="String" />
                        <ext:RecordField Name="DeliveryAddr" Type="String" />
                        <ext:RecordField Name="FinishDate" Type="Date" />
                        <ext:RecordField Name="ExpCompany" Type="String" />
                        <ext:RecordField Name="CompanyBank" Type="String" />
                        <ext:RecordField Name="CAccountNo" Type="String" />
                        <ext:RecordField Name="CBankAddr" Type="String" />
                        <ext:RecordField Name="CBankTel" Type="String" />
                        <ext:RecordField Name="BContact" Type="String" />
                        <ext:RecordField Name="BMail" Type="String" />
                        <ext:RecordField Name="BName" Type="String" />
                        <ext:RecordField Name="BBank" Type="String" />
                        <ext:RecordField Name="BAccountNo" Type="String" />
                        <ext:RecordField Name="AttachCount" Type="Float" />
                    </Fields>
                </ext:JsonReader>
            </Reader>
        </ext:Store>
        <ext:Store runat="server" ID="storeGoods" AutoLoad="true" ShowWarningOnFailure="false"
            OnRefreshData="storeGoods_Refresh" SkipIdForNewRecords="false" RefreshAfterSaving="Always">
            <Reader>
                <ext:JsonReader>
                    <Fields>
                        <ext:RecordField Name="ProNo" Type="String" />
                        <ext:RecordField Name="ItemNo" Type="String" />
                        <ext:RecordField Name="CustItemNo" Type="String" />
                        <ext:RecordField Name="Item_C_Name" Type="String" />
                        <ext:RecordField Name="Item_C_Spec" Type="String" />
                        <ext:RecordField Name="BUnit" Type="String" />
                        <ext:RecordField Name="CBUnit" Type="String" />
                        <ext:RecordField Name="UTRM" Type="String" />
                        <ext:RecordField Name="UTR" Type="String" />
                        <ext:RecordField Name="Unit" Type="String" />
                        <ext:RecordField Name="CUnit" Type="String" />
                        <ext:RecordField Name="Brand" Type="String" />
                        <ext:RecordField Name="Color" Type="String" />
                        <ext:RecordField Name="Material" Type="String" />
                        <ext:RecordField Name="PTFID" Type="String" />
                        <ext:RecordField Name="ManufNote" Type="String" />
                        <ext:RecordField Name="Packing" Type="String" />
                        <ext:RecordField Name="AddFld1" Type="String" />
                        <ext:RecordField Name="AddFld2" Type="String" />
                        <ext:RecordField Name="AddFld3" Type="String" />
                        <ext:RecordField Name="AddFld4" Type="String" />
                        <ext:RecordField Name="AddFld5" Type="String" />
                        <ext:RecordField Name="AddFld6" Type="String" />
                        <ext:RecordField Name="AddFld7" Type="String" />
                        <ext:RecordField Name="AddFld8" Type="String" />
                        <ext:RecordField Name="AddFld9" Type="String" />
                        <ext:RecordField Name="AddFld10" Type="String" />
                        <ext:RecordField Name="AddFld11" Type="String" />
                        <ext:RecordField Name="AddFld12" Type="String" />
                        <ext:RecordField Name="AddFld13" Type="String" />
                        <ext:RecordField Name="AddFld14" Type="String" />
                        <ext:RecordField Name="AddFld15" Type="String" />
                        <ext:RecordField Name="AddFld16" Type="String" />
                        <ext:RecordField Name="AddFld17" Type="String" />
                        <ext:RecordField Name="AddFld18" Type="String" />
                        <ext:RecordField Name="AddFld19" Type="String" />
                        <ext:RecordField Name="AddFld20" Type="String" />
                        <ext:RecordField Name="AddFld21" Type="String" />
                        <ext:RecordField Name="AddFld22" Type="String" />
                        <ext:RecordField Name="AddFld23" Type="String" />
                        <ext:RecordField Name="AddFld24" Type="String" />
                        <ext:RecordField Name="AddFld25" Type="String" />
                        <ext:RecordField Name="BSaleQty" Type="Float" />
                        <ext:RecordField Name="BSalePrice" Type="Float" />
                        <ext:RecordField Name="SaleQty" Type="Float" />
                        <ext:RecordField Name="OrgSalePrice" Type="Float" />
                        <ext:RecordField Name="OffRT" Type="Float" />
                        <ext:RecordField Name="OffAmt" Type="Float" />
                        <ext:RecordField Name="SalePrice" Type="Float" />
                        <ext:RecordField Name="SaleAmt" Type="Float" />
                        <ext:RecordField Name="VATRT" Type="Float" />
                        <ext:RecordField Name="VAT" Type="Float" />
                        <ext:RecordField Name="NTSalePrice" Type="Float" />
                        <ext:RecordField Name="NTSaleAmt" Type="Float" />
                        <ext:RecordField Name="CQNo" Type="String" />
                        <ext:RecordField Name="SONo" Type="String" />
                    </Fields>
                </ext:JsonReader>
            </Reader>
            <BaseParams>
                <ext:Parameter Name="ScNo" Value="Ext.getCmp('#{gpList}') && #{gpList}.getSelectionModel().hasSelection() ? #{gpList}.getSelectionModel().getSelected().id : -1"
                    Mode="Raw" />
            </BaseParams>
            <Listeners>
                <LoadException Handler="Ext.Msg.alert('加载失败', e.message || response.statusText);" />
            </Listeners>
        </ext:Store>
        <ext:Store runat="server" ID="storePayments" AutoLoad="true" ShowWarningOnFailure="false"  OnRefreshData="storePayments_Refresh"
            SkipIdForNewRecords="false" RefreshAfterSaving="Always">
            <Reader>
                <ext:JsonReader>
                    <Fields>
                        <ext:RecordField Name="CostTyp" Type="Int" />
                        <ext:RecordField Name="CostDesc" Type="String" />
                        <ext:RecordField Name="Ratio" Type="Float" />
                        <ext:RecordField Name="CostAmt" Type="String" />
                        <ext:RecordField Name="Memo" Type="String" />
                    </Fields>
                </ext:JsonReader>
            </Reader>
            <BaseParams>
                <ext:Parameter Name="ScNo" Value="Ext.getCmp('#{gpList}') && #{gpList}.getSelectionModel().hasSelection() ? #{gpList}.getSelectionModel().getSelected().id : -1"
                    Mode="Raw" />
            </BaseParams>
            <Listeners>
                <LoadException Handler="Ext.Msg.alert('加载失败', e.message || response.statusText);" />
            </Listeners>
        </ext:Store>
        <ext:Store runat="server" ID="storeRecord" AutoLoad="true" ShowWarningOnFailure="false"  OnRefreshData="storeRecord_Refresh"
            SkipIdForNewRecords="false" RefreshAfterSaving="Always">
            <Reader>
                <ext:JsonReader>
                    <Fields>
                        <ext:RecordField Name="pPayDate" Type="Date" />
                        <ext:RecordField Name="PayDesc" Type="String" />
                        <ext:RecordField Name="Ratio" Type="String" />
                        <ext:RecordField Name="PayAmt" Type="String" />
                        <ext:RecordField Name="Memo" Type="String" />
                        <ext:RecordField Name="IsPay" Type="String" />
                        <ext:RecordField Name="PayDate" Type="Date" />
                        <ext:RecordField Name="CheckAmt" Type="String" />
                    </Fields>
                </ext:JsonReader>
            </Reader>
            <BaseParams>
                <ext:Parameter Name="ScNo" Value="Ext.getCmp('#{gpList}') && #{gpList}.getSelectionModel().hasSelection() ? #{gpList}.getSelectionModel().getSelected().id : -1"
                    Mode="Raw" />
            </BaseParams>
            <Listeners>
                <LoadException Handler="Ext.Msg.alert('加载失败', e.message || response.statusText);" />
            </Listeners>
        </ext:Store>
        <ext:Store runat="server" ID="storeContract" AutoLoad="true" ShowWarningOnFailure="false"  OnRefreshData="storeContract_Refresh"
            SkipIdForNewRecords="false" RefreshAfterSaving="Always">
            <Reader>
                <ext:JsonReader>
                    <Fields>
                        <ext:RecordField Name="Term" Type="String" />
                    </Fields>
                </ext:JsonReader>
            </Reader>
            <BaseParams>
                <ext:Parameter Name="ScNo" Value="Ext.getCmp('#{gpList}') && #{gpList}.getSelectionModel().hasSelection() ? #{gpList}.getSelectionModel().getSelected().id : -1"
                    Mode="Raw" />
            </BaseParams>
            <Listeners>
                <LoadException Handler="Ext.Msg.alert('加载失败', e.message || response.statusText);" />
            </Listeners>
        </ext:Store>
        <ext:Viewport ID="Viewport1" runat="server" Layout="FitLayout">
            <Items>
                <ext:RowLayout ID="RowLayout1" runat="server">
                    <Rows>
                        <ext:LayoutRow RowHeight="0.04">
                            <ext:Panel runat="server" ID="TopBar">
                            </ext:Panel>
                        </ext:LayoutRow>
                        <ext:LayoutRow RowHeight="0.957">
                            <ext:Panel runat="server" Border="false">
                                <Items>
                                    <ext:BorderLayout runat="server">
                                        <West MinWidth="10" MaxWidth="500" Split="true" CollapseMode="Mini">
                                            <ext:Panel ID="Panel5" runat="server" Width="230" AutoScroll="true">
                                                <Items>
                                                    <ext:TabPanel runat="server" Padding="4" Border="false">
                                                        <Items>
                                                            <ext:Panel runat="server" Title="查询" Border="false">
                                                                <Items>
                                                                    <ext:Label ID="Label1" runat="server" Html="<font   style='font-weight:bolder;font-size:13px' >按下面任何标准进行搜索</font>" />
                                                                    <ext:Panel ID="Panel7" runat="server" Border="false" Padding="5">
                                                                        <Items>
                                                                            <ext:FormPanel ID="FormPanel3" Border="false" runat="server" Padding="5" LabelWidth="70">
                                                                                <Items>
                                                                                    <ext:CompositeField ID="CompositeField1" AnchorHorizontal="100%" runat="server" LabelAlign="Top"
                                                                                        FieldLabel="关键字">
                                                                                        <Items>
                                                                                            <ext:TextField ID="txtKeyWord" EmptyText="关键字" LabelAlign="Top" runat="server" Width="120" />
                                                                                        </Items>
                                                                                    </ext:CompositeField>
                                                                                    <ext:CompositeField ID="CompositeField2" runat="server" FieldLabel="在这儿查找">
                                                                                        <Items>
                                                                                            <ext:MultiCombo runat="server" Width="120" ID="cobSelect" EmptyText="请选择寻找范围" SelectionMode="Checkbox">
                                                                                                <Items>
                                                                                                    <ext:ListItem Text="客户编号" Value="1" />
                                                                                                    <ext:ListItem Text="审核标志" Value="2" />
                                                                                                    <ext:ListItem Text="业务员" Value="3" />
                                                                                                    <ext:ListItem Text="客户全名" Value="4" />
                                                                                                </Items>
                                                                                            </ext:MultiCombo>
                                                                                        </Items>
                                                                                    </ext:CompositeField>
                                                                                    <ext:CompositeField ID="CompositeField3" runat="server" FieldLabel="精确查找">
                                                                                        <Items>
                                                                                            <ext:Checkbox ID="chkExactMatch" runat="server" FieldLabel="精确查找">
                                                                                            </ext:Checkbox>
                                                                                        </Items>
                                                                                    </ext:CompositeField>
                                                                                </Items>
                                                                            </ext:FormPanel>
                                                                        </Items>
                                                                    </ext:Panel>
                                                                    <ext:Panel ID="Panel8" Border="false" runat="server" Title="更多高级选项" FormGroup="true"
                                                                        Padding="5">
                                                                        <Items>
                                                                            <ext:FormPanel ID="FormPanel1" Border="false" runat="server" Padding="5" LabelWidth="70">
                                                                                <Items>
                                                                                    <ext:CompositeField ID="CompositeField4" AnchorHorizontal="100%" runat="server" FieldLabel="客户">
                                                                                        <Items>
                                                                                            <ext:TriggerField ID="tfDeptID" EmptyText="客户" runat="server" Width="120">
                                                                                                <Triggers>
                                                                                                    <ext:FieldTrigger Icon="Ellipsis" Qtip="客户" />
                                                                                                </Triggers>
                                                                                            </ext:TriggerField>
                                                                                        </Items>
                                                                                    </ext:CompositeField>
                                                                                </Items>
                                                                            </ext:FormPanel>
                                                                        </Items>
                                                                    </ext:Panel>
                                                                    <ext:Panel runat="server" Padding="30" Region="Center" Border="false">
                                                                        <Items>
                                                                            <ext:CompositeField ID="CompositeField6" runat="server" Region="Center">
                                                                                <Items>
                                                                                    <ext:Button ID="btn_Search" runat="server" Text="搜索" Width="70">
                                                                                        <Listeners>
                                                                                            <Click Handler="Ext.net.DirectMethods.btnSearch()" />
                                                                                        </Listeners>
                                                                                    </ext:Button>
                                                                                    <ext:Button ID="btmReset" runat="server" Text="清空" Width="70">
                                                                                        <Listeners>
                                                                                            <Click Handler="Ext.net.DirectMethods.btnReset()" />
                                                                                        </Listeners>
                                                                                    </ext:Button>
                                                                                </Items>
                                                                            </ext:CompositeField>
                                                                        </Items>
                                                                    </ext:Panel>
                                                                </Items>
                                                            </ext:Panel>
                                                        </Items>
                                                    </ext:TabPanel>
                                                </Items>
                                            </ext:Panel>
                                        </West>
                                        <Center>
                                            <ext:Panel runat="server" Border="false" AutoScroll="true">
                                                <Items>
                                                    <ext:BorderLayout ID="BorderLayout1" runat="server">
                                                        <Center>
                                                            <ext:Panel ID="Panel3" Border="false" runat="server" Layout="FitLayout">
                                                                <Items>
                                                                    <ext:GridPanel runat="server" ID="gpList" StoreID="storeDomestic" TrackMouseOver="true">
                                                                        <ColumnModel runat="server">
                                                                            <Columns>
                                                                                <ext:RowNumbererColumn Locked="true" />
                                                                                <ext:Column DataIndex="ScNo" Header="销合同编号" Locked="true" />
                                                                                <ext:Column DataIndex="CustID" Header="客户编号" Locked="true" />
                                                                                <ext:Column DataIndex="BriefName" Header="客户简称" Locked="true" />
                                                                                <ext:DateColumn DataIndex="CreateDate" Header="签约日期" Locked="true" Format="yyyy-MM-dd" />
                                                                                <ext:Column DataIndex="SMTyp" Header="销售方式" />
                                                                                <ext:Column DataIndex="CustPONo" Header="客户订单编号" />
                                                                                <ext:Column DataIndex="Memo" Header="备注" />
                                                                                <ext:Column DataIndex="OwnerID" Header="拥有人" />
                                                                                <ext:Column DataIndex="OwnerName" Header="拥有人名称" />
                                                                                <ext:Column DataIndex="KeyInID" Header="录入人工号" />
                                                                                <ext:Column DataIndex="keyInName" Header="录入人名称" />
                                                                                <ext:DateColumn DataIndex="KeyInDate" Header="录入日期" Format="yyyy-MM-dd" />
                                                                                <ext:DateColumn DataIndex="keyInTime" Header="录入时间" Format="yyyy-MM-dd" />
                                                                                <ext:Column DataIndex="LastEditMan" Header="最后一次修改人" />
                                                                                <ext:DateColumn DataIndex="LastEditDate" Header="最后一次修改日期" Format="yyyy-MM-dd" />
                                                                                <ext:Column DataIndex="AuditState" Header="审核标志" />
                                                                                <ext:Column DataIndex="IsDeleted" Header="作废" />
                                                                                <ext:Column DataIndex="SaleID" Header="业务员" />
                                                                                <ext:Column DataIndex="SaleName" Header="业务员名称" />
                                                                                <ext:Column DataIndex="DeptID" Header="销售部门" />
                                                                                <ext:Column DataIndex="DeptName" Header="销售部门名称" />
                                                                                <ext:Column DataIndex="CUR" Header="结算币种" />
                                                                                <ext:Column DataIndex="RMBEXR" Header="人民币汇率" />
                                                                                <ext:Column DataIndex="USEXR" Header="美元汇率" />
                                                                                <ext:Column DataIndex="TotProdAmt" Header="商品总金额" />
                                                                                <ext:Column DataIndex="TotAddFee" Header="其他增加款项" />
                                                                                <ext:Column DataIndex="TotDeductFee" Header="其他扣除款项" />
                                                                                <ext:Column DataIndex="TotVAT" Header="销项税总计" />
                                                                                <ext:Column DataIndex="PaymentMode" Header="付款方式" />
                                                                                <ext:Column DataIndex="DeliveryAddr" Header="送货地址" />
                                                                                <ext:DateColumn DataIndex="FinishDate" Header="交货期" Format="yyyy-MM-dd" />
                                                                                <ext:Column DataIndex="ExpCompany" Header="收款公司" />
                                                                                <ext:Column DataIndex="CompanyBank" Header="收款银行" />
                                                                                <ext:Column DataIndex="CAccountNo" Header="收款银行账号" />
                                                                                <ext:Column DataIndex="CBankAddr" Header="收款银行地址" />
                                                                                <ext:Column DataIndex="CBankTel" Header="收款银行电话" />
                                                                                <ext:Column DataIndex="BContact" Header="客户联系人" />
                                                                                <ext:Column DataIndex="BMail" Header="客户联系人邮箱" />
                                                                                <ext:Column DataIndex="BName" Header="客户全名" />
                                                                                <ext:Column DataIndex="BBank" Header="客户银行名" />
                                                                                <ext:Column DataIndex="BAccountNo" Header="客户银行账户" />
                                                                                <ext:Column DataIndex="AttachCount" Header="附件数" />
                                                                            </Columns>
                                                                        </ColumnModel>
                                                                        <View>
                                                                            <ext:LockingGridView />
                                                                        </View>
                                                                        <BottomBar>
                                                                            <ext:PagingToolbar runat="server" PageSize="30">
                                                                            </ext:PagingToolbar>
                                                                        </BottomBar>
                                                                        <%--       <Listeners>
                                                                            <Click Fn="details" />
                                                                        </Listeners>--%>
                                                                        <SelectionModel>
                                                                            <ext:RowSelectionModel ID="RowSelectionModel2" runat="server" SingleSelect="true">
                                                                                <Listeners>
                                                                                    <RowSelect Handler="if (#{pnlGoods}.isVisible()) {#{storeGoods}.reload();}if (#{pnlPayments}.isVisible()) {#{storePayments}.reload();}if (#{pnlRecord}.isVisible()) {#{storeRecord}.reload();}if (#{pnlContract}.isVisible()) {#{storeContract}.reload();}"
                                                                                        Buffer="250" />
                                                                                </Listeners>
                                                                            </ext:RowSelectionModel>
                                                                        </SelectionModel>
                                                                        <LoadMask ShowMask="true" />
                                                                    </ext:GridPanel>
                                                                </Items>
                                                            </ext:Panel>
                                                        </Center>
                                                        <South Split="true" CollapseMode="Mini">
                                                            <ext:TabPanel runat="server" Height="300" Border="false">
                                                                <Items>
                                                                    <ext:Panel runat="server" ID="pnlGoods" Title="商品清单" Border="false">
                                                                        <Items>
                                                                            <ext:GridPanel runat="server" TrackMouseOver="true" Height="270" StoreID="storeGoods">
                                                                                <ColumnModel runat="server">
                                                                                    <Columns>
                                                                                        <ext:RowNumbererColumn Locked="true" />
                                                                                        <ext:Column DataIndex="ProNo" Header="标准型号" Locked="true" />
                                                                                        <ext:Column DataIndex="ItemNo" Header="商品编号" Locked="true" />
                                                                                        <ext:Column DataIndex="CustItemNo" Header="客户货号" Locked="true" />
                                                                                        <ext:Column DataIndex="Item_C_Name" Header="商品中文名" Locked="true" />
                                                                                        <ext:Column DataIndex="Item_C_Spec" Header="商品中文规格" />
                                                                                        <ext:Column DataIndex="BUnit" Header="基本计量单位" />
                                                                                        <ext:Column DataIndex="CBUnit" Header="中文基本计量单位" />
                                                                                        <ext:Column DataIndex="UTRM" Header="计量单位转换" />
                                                                                        <ext:Column DataIndex="UTR" Header="计量单位转换率" />
                                                                                        <ext:Column DataIndex="Unit" Header="计量单位" />
                                                                                        <ext:Column DataIndex="CUnit" Header="中文计量单位" />
                                                                                        <ext:Column DataIndex="Brand" Header="商标" />
                                                                                        <ext:Column DataIndex="Color" Header="颜色" />
                                                                                        <ext:Column DataIndex="Material" Header="材料" />
                                                                                        <ext:Column DataIndex="PTFID" Header="包装方案" />
                                                                                        <ext:Column DataIndex="ManufNote" Header="生产要求" />
                                                                                        <ext:Column DataIndex="Packing" Header="包装要求" />
                                                                                        <ext:Column DataIndex="AddFld1" Header="附近属性1" />
                                                                                        <ext:Column DataIndex="AddFld2" Header="附近属性2" />
                                                                                        <ext:Column DataIndex="AddFld3" Header="附近属性3" />
                                                                                        <ext:Column DataIndex="AddFld4" Header="附近属性4" />
                                                                                        <ext:Column DataIndex="AddFld5" Header="附近属性5" />
                                                                                        <ext:Column DataIndex="AddFld6" Header="附近属性6" />
                                                                                        <ext:Column DataIndex="AddFld7" Header="附近属性7" />
                                                                                        <ext:Column DataIndex="AddFld8" Header="附近属性8" />
                                                                                        <ext:Column DataIndex="AddFld9" Header="附近属性9" />
                                                                                        <ext:Column DataIndex="AddFld10" Header="附近属性10" />
                                                                                        <ext:Column DataIndex="AddFld11" Header="附近属性11" />
                                                                                        <ext:Column DataIndex="AddFld12" Header="附近属性12" />
                                                                                        <ext:Column DataIndex="AddFld13" Header="附近属性13" />
                                                                                        <ext:Column DataIndex="AddFld14" Header="附近属性14" />
                                                                                        <ext:Column DataIndex="AddFld15" Header="附近属性15" />
                                                                                        <ext:Column DataIndex="AddFld16" Header="附近属性16" />
                                                                                        <ext:Column DataIndex="AddFld17" Header="附近属性17" />
                                                                                        <ext:Column DataIndex="AddFld18" Header="附近属性18" />
                                                                                        <ext:Column DataIndex="AddFld19" Header="附近属性19" />
                                                                                        <ext:Column DataIndex="AddFld20" Header="附近属性20" />
                                                                                        <ext:Column DataIndex="AddFld21" Header="附近属性21" />
                                                                                        <ext:Column DataIndex="AddFld22" Header="附近属性22" />
                                                                                        <ext:Column DataIndex="AddFld23" Header="附近属性23" />
                                                                                        <ext:Column DataIndex="AddFld24" Header="附近属性24" />
                                                                                        <ext:Column DataIndex="AddFld25" Header="附近属性25" />
                                                                                        <ext:Column DataIndex="BSaleQty" Header="基本计量单位销售数量" />
                                                                                        <ext:Column DataIndex="BSalePrice" Header="基本计量单位销售单价" />
                                                                                        <ext:Column DataIndex="SaleQty" Header="销售数量" />
                                                                                        <ext:Column DataIndex="OrgSalePrice" Header="销售单价" />
                                                                                        <ext:Column DataIndex="OffRT" Header="折扣比率(%)" />
                                                                                        <ext:Column DataIndex="OffAmt" Header="折扣金额" />
                                                                                        <ext:Column DataIndex="SalePrice" Header="实际销售单价" />
                                                                                        <ext:Column DataIndex="SaleAmt" Header="实际销售金额" />
                                                                                        <ext:Column DataIndex="VATRT" Header="销项税率(%)" />
                                                                                        <ext:Column DataIndex="VAT" Header="销项税额" />
                                                                                        <ext:Column DataIndex="NTSalePrice" Header="不含税单价" />
                                                                                        <ext:Column DataIndex="NTSaleAmt" Header="不含税金额" />
                                                                                        <ext:Column DataIndex="CQNo" Header="报价单编号" />
                                                                                        <ext:Column DataIndex="SONo" Header="销售机会编号" />
                                                                                    </Columns>
                                                                                </ColumnModel>
                                                                                <View>
                                                                                    <ext:LockingGridView />
                                                                                </View>
                                                                                <SelectionModel>
                                                                                    <ext:RowSelectionModel runat="server" SingleSelect="true" />
                                                                                </SelectionModel>
                                                                                <Listeners>
                                                                                    <Expand Handler="#{storeGoods}.reload();" />
                                                                                </Listeners>
                                                                                <LoadMask ShowMask="true" />
                                                                            </ext:GridPanel>
                                                                        </Items>
                                                                    </ext:Panel>
                                                                    <ext:Panel ID="pnlPayments" AutoHeight="true" runat="server" Title="其他款项" Border="false">
                                                                        <Items>
                                                                            <ext:GridPanel runat="server" TrackMouseOver="true" StoreID="storePayments" Height="270">
                                                                                <ColumnModel runat="server">
                                                                                    <Columns>
                                                                                        <ext:RowNumbererColumn />
                                                                                        <ext:Column Header="款项性质" DataIndex="CostTyp" />
                                                                                        <ext:Column Header="款项描述" DataIndex="CostDesc" />
                                                                                        <ext:Column Header="比率(%)" DataIndex="Ratio" />
                                                                                        <ext:Column Header="默认金额" DataIndex="CostAmt" />
                                                                                        <ext:Column Header="备注" DataIndex="Memo" />
                                                                                    </Columns>
                                                                                </ColumnModel>
                                                                                <SelectionModel>
                                                                                    <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" SingleSelect="true" />
                                                                                </SelectionModel>
                                                                                <Listeners>
                                                                                    <Expand Handler="#{storePayments}.reload();" />
                                                                                </Listeners>
                                                                                <LoadMask ShowMask="true" />
                                                                            </ext:GridPanel>
                                                                        </Items>
                                                                    </ext:Panel>
                                                                    <ext:Panel ID="pnlRecord" AutoHeight="true" runat="server" Title="预收款记录" Border="false">
                                                                        <Items>
                                                                            <ext:GridPanel runat="server" TrackMouseOver="true" StoreID="storeRecord" Height="270">
                                                                                <ColumnModel ID="ColumnModel1" runat="server">
                                                                                    <Columns>
                                                                                        <ext:RowNumbererColumn />
                                                                                        <ext:Column Header="协议付款日期" DataIndex="pPayDate" />
                                                                                        <ext:Column Header="描述" DataIndex="PayDesc" />
                                                                                        <ext:Column Header="比率(%)" DataIndex="Ratio" />
                                                                                        <ext:Column Header="金额" DataIndex="PayAmt" />
                                                                                        <ext:Column Header="备注" DataIndex="Memo" />
                                                                                        <ext:Column Header="已核销" DataIndex="IsPay" />
                                                                                        <ext:Column Header="核销日期" DataIndex="PayDate" />
                                                                                        <ext:Column Header="核销金额" DataIndex="CheckAmt" />
                                                                                    </Columns>
                                                                                </ColumnModel>
                                                                                <SelectionModel>
                                                                                    <ext:RowSelectionModel ID="RowSelectionModel3" runat="server" SingleSelect="true" />
                                                                                </SelectionModel>
                                                                                <Listeners>
                                                                                    <Expand Handler="#{storeRecord}.reload();" />
                                                                                </Listeners>
                                                                                <LoadMask ShowMask="true" />
                                                                            </ext:GridPanel>
                                                                        </Items>
                                                                    </ext:Panel>
                                                                    <ext:Panel ID="pnlContract" Height="270" runat="server" Title="合同条款" Border="false">
                                                                        <Items>
                                                                            <ext:GridPanel ID="GridPanel2" runat="server" TrackMouseOver="true" StoreID="storeContract">
                                                                                <ColumnModel ID="ColumnModel2" runat="server">
                                                                                    <Columns>
                                                                                        <ext:RowNumbererColumn />
                                                                                        <ext:Column Header="条款" DataIndex="Term" />
                                                                                    </Columns>
                                                                                </ColumnModel>
                                                                                <SelectionModel>
                                                                                    <ext:RowSelectionModel ID="RowSelectionModel4" runat="server" SingleSelect="true" />
                                                                                </SelectionModel>
                                                                                <Listeners>
                                                                                    <Expand Handler="#{storeContract}.reload();" />
                                                                                </Listeners>
                                                                                <LoadMask ShowMask="true" />
                                                                            </ext:GridPanel>
                                                                        </Items>
                                                                    </ext:Panel>
                                                                </Items>
                                                            </ext:TabPanel>
                                                        </South>
                                                    </ext:BorderLayout>
                                                </Items>
                                            </ext:Panel>
                                        </Center>
                                    </ext:BorderLayout>
                                </Items>
                            </ext:Panel>
                        </ext:LayoutRow>
                    </Rows>
                </ext:RowLayout>
            </Items>
        </ext:Viewport>
    </div>
    </form>

  CS:

 

   #region  Refresh  GridPanel 加载 方案二
        protected void storeGoods_Refresh(object sender, StoreRefreshDataEventArgs e)
        {
            string strID = e.Parameters["ScNo"];
            if (string.IsNullOrEmpty(strID))
                return;
            Refresh(strID);
        }
        protected void storeRecord_Refresh(object sender, StoreRefreshDataEventArgs e)
        {
            string strID = e.Parameters["ScNo"];
            if (string.IsNullOrEmpty(strID))
                return;
            Refresh(strID);
        }
        protected void storePayments_Refresh(object sender, StoreRefreshDataEventArgs e)
        {
            string strID = e.Parameters["ScNo"];
            if (string.IsNullOrEmpty(strID))
                return;
            Refresh(strID);
        }
        protected void storeContract_Refresh(object sender, StoreRefreshDataEventArgs e)
        {
            string strID = e.Parameters["ScNo"];
            if (string.IsNullOrEmpty(strID))
                return;
            Refresh(strID);
        }

        private void Refresh(string strID)
        {
            DataRow[] itemPanelList = structTabPageTable.Select("TreeLevel=2 AND StrucLevel<3 AND IsStruc=1 ");
            for (int i = 0; i < itemPanelList.Length; i++)
            {
                DataTable mould = MouldDao.GetMouldTables(structStr, itemPanelList[i]["SQLNo"].ToString());
                DataTable field;
                string index = string.Empty;
                index = itemPanelList[i]["SQLNo"].ToString();
                field = MouldDao.GetMouldFiledsOrderByOrderNo(structStr, index);
                dataCommand = MouldDao.GetDataCommand(mould, field);
                dataCommand.Append(" WHERE  ScNo='" + strID + "'");
                DataTable source = MouldDao.GetDataSource(dataCommand.ToString());
                if (i == 0)
                {
                    storeGoods.DataSource = source;
                    storeGoods.DataBind();
                }

                if (i == 2)
                {
                    storeRecord.DataSource = source;
                    storeRecord.DataBind();
                }
                if (i == 1)
                {
                    storePayments.DataSource = source;
                    storePayments.DataBind();
                }
                if (i == 3)
                {
                    storeContract.DataSource = source;
                    storeContract.DataBind();
                }
            }
        }
        #endregion

  

 

 

方案叁2011-11-21:

上周功能是实现了,领导说好像有点慢……

分析了一下发现性能上不好,因为单击选择一行“一对多” 多个一起加载 性能上大打折扣。

 今天整理下

给“一对多”的这个“多”Panel 每个加一个事件Listeners

<Listeners>
<Activate Handler="#{storeGoods}.reload();" />
</Listeners>

 当TabPanel中的Panel切换到当前Panel则执行事件

protected void storeGoods_Refresh(object sender, StoreRefreshDataEventArgs e)

读取数据加载……

 

效果一样精彩,目前来说推荐方案叁  。。。。。

 

 

 

 

 

 

八:Store OnBeforeStoreChanged

      

 

protected void store_BeforeChanged(object sender, BeforeStoreChangedEventArgs e)
{
XmlDocument xml = e.DataHandler.XmlData;
ChangedData("5", xml, store5);//根据条件修改GridPanl 中Store值
Refresh(1, store, "5"); //修改完 再加载Store
}

 

 

 

 

 

继续跟进……


作者:PEPE
出处:http://pepe.cnblogs.com/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

你可能感兴趣的:(GridView)