你的位置:首页 > ASP.net教程

[ASP.net教程]Ext.Net GridPanel RowSelect 行选择事件


GridPanel中选中行,后台获取行json信息,再进行相关处理

<ext:GridPanel ID="GridPanel1" runat="server" StoreID="Store1" StripeRows="true"
Title="Purchase Order" AutoExpandColumn="Company" Collapsible="true" EnableColumnMove="true"
Height="380" Header="false" Region="Center">
      <ColumnModel ID="ColumnModel1" runat="server">
            <Columns>
            <ext:Column ColumnID="Company" Header="Purchase Order" Align="Center" Width="200"
            DataIndex="Name" />
            </Columns>
      </ColumnModel>
      <SelectionModel>
            <ext:RowSelectionModel>
                  <DirectEvents>
                        <RowSelect OnEvent="Cell_Click">
                              <ExtraParams>
                                    <ext:Parameter Name="Values" Value="Ext.encode(#{GridPanel1}.getRowsValues({selectedOnly:true}))"
                                    Mode="Raw" />
                              </ExtraParams>
                        </RowSelect>
                  </DirectEvents>
            </ext:RowSelectionModel>
      </SelectionModel>
</ext:GridPanel>

后台CS:

protected void Cell_Click(object sender, DirectEventArgs e)
{
string json = e.ExtraParams["Values"];
Dictionary<string, string>[] companies = JSON.Deserialize<Dictionary<string, string>[]>(json);
foreach (Dictionary<string, string> row in companies)
{
foreach (KeyValuePair<string, string> keyValuePair in row)
{
string s=keyValuePair.Value;//Value值
}
}
}