前台代码:
<ext:Button ID="SubmitSelection" runat="server" Text="遍历数据" Icon="PageWhiteEdit"
ToolTip="遍历数据">
<DirectEvents>
<Click OnEvent="SubmitSelection_Click">
<ExtraParams>
<ext:Parameter Name="Values" Value="Ext.encode(#{GridPanelMain}.getRowsValues({selectedOnly : true}))"
Mode="Raw" />
</ExtraParams>
</Click>
</DirectEvents>
</ext:Button>
后台代码
[DirectMethod]
protected void SubmitSelection_Click(object sender, Ext.Net.DirectEventArgs e)
{
string json = e.ExtraParams["Values"];
if (string.IsNullOrEmpty(json))
{
return;
}
//<records><record><DictCode>JQFL</DictCode>
//<DictName>警情分类</DictName>
//<DictValue>
// </DictValue>
//<IsSystem>true
// </IsSystem><IsShow>true</IsShow><IsUse>true</IsUse><DisplayOrder>37</DisplayOrder><Creator>开发人员
// </Creator><CreateTime>2012-03-05T13:59:06</CreateTime><Editor /></record>
//</records>
XmlNode xml = JSON.DeserializeXmlNode("{records:{record:" + json + "}}");
foreach (XmlNode row in xml.SelectNodes("records/record"))
{
string DictCode = row.SelectSingleNode("DictCode").InnerXml;
string DictName = row.SelectSingleNode("DictName").InnerXml;
string DictValue = row.SelectSingleNode("DictValue").InnerXml;
string CreateTime = row.SelectSingleNode("CreateTime").InnerXml;
}
List<sys_Dict> Dicts = JSON.Deserialize<List<sys_Dict>>(json);
foreach (sys_Dict Dict in Dicts)
{
string name = Dict.DictName;
}
Dictionary<string, string>[] Dicts1 = JSON.Deserialize<Dictionary<string, string>[]>(json);
foreach (Dictionary<string, string> row in Dicts1)
{
string name = row["DictName"];
}
this.ResourceManagerMain.AddScript("Ext.Msg.alert('Submitted', 'Please see source code how to handle submitted data');");
}