Ext.Net 1.x_Ext.Net.GridPanel如何后台遍历GridPanel中的数据?

Ext.Net
专注与Ext.Net 控件用法,分享优秀JS库。
厦门德仔

A:

参见

  1. http://examples.ext.net/#/GridPanel/Selection_Models/Submitting_Values/
  2. http://examples.ext.net/#/GridPanel/Selection_Models/Row_Selection/

要点,前台提取数据,后台解析JSON字符串。

前台:

<Buttons> 
            <ext:Button runat="server" Text="Submit selection"> 
                <DirectEvents> 
                    <Click OnEvent="SubmitSelection"> 
                        <ExtraParams> 
                            <ext:Parameter Name="Values" Value="Ext.encode(#{GridPanel1}.getRowsValues({selectedOnly : true}))" Mode="Raw" /> 
                        </ExtraParams> 
                    </Click> 
                </DirectEvents> 
            </ext:Button> 
        </Buttons>

后台:

protected void SubmitSelection(object sender, DirectEventArgs e) 
{ 
    string json = e.ExtraParams["Values"]; 
      
    if (string.IsNullOrEmpty(json)) 
    { 
        return; 
    } 
      
    //XML will be represent as 
    //<records> 
    //   <record><Name>Alcoa Inc</Name><Price>29.01</Price><Change>0.42</Change><PctChange>1.47</PctChange></record> 
    //        ...   
    //   <record>...</record> 
    //</records> 
    XmlNode xml = JSON.DeserializeXmlNode("{records:{record:" + json + "}}"); 
  
    foreach (XmlNode row in xml.SelectNodes("records/record")) 
    { 
        string name = row.SelectSingleNode("Name").InnerXml; 
        string price = row.SelectSingleNode("Price").InnerXml; 
        string change = row.SelectSingleNode("Change").InnerXml; 
        string pctChange = row.SelectSingleNode("PctChange").InnerXml; 
          
        //handle values 
    } 
      
    List<Company> companies = JSON.Deserialize<List<Company>>(json); 
  
    foreach (Company company in companies) 
    { 
        string name = company.Name; 
        double price = company.Price; 
        double change = company.Change; 
        double pctChange = company.PctChange; 
  
        //handle values 
    } 
      
    Dictionary<string, string>[] companies1 = JSON.Deserialize<Dictionary<string, string>[]>(json); 
  
    foreach (Dictionary<string, string> row in companies1) 
    { 
        string name = row["Name"]; 
        string price = row["Price"]; 
        string change = row["Change"]; 
        string pctChange = row["PctChange"]; 
  
        //handle values 
    } 
      this.ResourceManager1.AddScript("Ext.Msg.alert('Submitted', 'Please see source code how to handle submitted data');"); 

}

展开阅读全文
©️2020 CSDN 皮肤主题: 鲸 设计师: meimeiellie 返回首页
实付99.00元
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值