天天看點

Dev控件用法 aspxTreeList 無重新整理 aspxGridView 資料

作者:躺平攻城獅

主要是利用 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  遞加           

繼續閱讀