主要是利用 ASPxTreeList 点击事件回发服务器进行数据重新绑定
ASPxTreeList:
<SettingsBehavior ExpandCollapseAction="NodeDblClick" AllowFocusedNode="True" AllowSort="False" />
<ClientSideEvents FocusedNodeChanged="function(s, e) { onFocusChanged(s,e);}" Init="function(s, e) { }" />
js代码如下:
if ($("ASPxTreeList1") != null) {
if (ASPxTreeList1.GetFocusedNodeKey != null || ASPxTreeList1.GetFocusedNodeKey != undefined) {
key = ASPxTreeList1.GetFocusedNodeKey();
}
} ASPxTreeList1.PerformCustomDataCallback(key); //数据传输回调方法 ASPxTreeList1.PerformCustomCallback(key); //数据绑定回调方法
ASPxGridView
oncustomcallback="ASPxGridView1_CustomCallback"
js中的performcallback方法捎带的参数来进行aspxgridview数据更新,通过aspxgridview的customcallback来实现
js代码如下:
function onFocusChanged(s,e) {
var key = "";
if ($("ASPxTreeList1") != null) {
if (ASPxTreeList1.GetFocusedNodeKey != null || ASPxTreeList1.GetFocusedNodeKey != undefined) {
key = ASPxTreeList1.GetFocusedNodeKey();
}
}
ASPxGridView1.PerformDataCallback(key); //数据传输回调方法 ASPxGridView1.PerformCallback(key); //数据绑定回调方法 }
C#回调方法:
protected void ASPxGridView1_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e)
{
string parm = e.Parameters.Trim(); //有的时候参数可能带有 "," 需要做判断
try
{
if (!string.IsNullOrEmpty(parm))
{
ASPxGridView1.DataSource = ModuleCode.SelectModuleQuery(parm).Tables[0];
ASPxGridView1.DataBind();
}
} catch (Exception ex) { }
}
获取ASPxGridView1选择行的值
KeyFieldName="POSTCODEID" PreviewFieldName="POSTNAME,State,IsDelete">
<ClientSideEvents FocusedRowChanged="function(s, e) { OnGridFocusedRowChanged(); }"/> <dxwgv:GridViewDataDateColumn Caption="岗位" FieldName="POSTCODE"></dxwgv:GridViewDataDateColumn>
每个项 FieldName="POSTCODE" 隐藏也能取到值
js代码如下:
function OnGridFocusedRowChanged(index) {
ASPxGridView1.GetRowValues(index, 'POSTCODEID;POSTNAME;POSTCODE;State;IsDelete', OnGetRowValues);
}
// 处理服务器端传回的数据(values是个数组)
function OnGetRowValues(values) {}
C#回调方法:
index = ASPxGridView1 的ASPxGridView1_HtmlRowPrepared 递加