Client side event that fires after ASPxClientGridView.ApplyFilter performs its work

社会主义新天地 提交于 2020-01-04 14:02:23

问题


This link explains how to handle it on the server side via the ASPxGridView.AfterPerformCallback event:

http://www.devexpress.com/Support/Center/p/Q274366.aspx

How can I handle it on the client side?

I am working on a custom server control and I have this client side function on my control:

    applyFilterToGridView: function () {
        this.theGridView.ApplyFilter(this.filterCondition); 
        this.filterAppliedEvent();
    }

Because ApplyFilter does a callback, this.filterAppliedEvent() is not called at the right time which should be after the filtering is complete. this.filterAppliedEvent() is a client side function.

This event is fired after the filter is applied:

protected void theGridView_AfterPerformCallback(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewAfterPerformCallbackEventArgs e)
        {
            if (e.CallbackName == "APPLYFILTER")
            {
            }
        }

Is there some way to to tell the client to call filterAppliedEvent from the AfterPerformCallback event?

I would prefer to be able to run this.filterAppliedEvent() after AfterPerformCallback on the client side if possible.

Thanks in advance.

EDIT ( Solution thanks to Filip ):

C#:

  protected void theGridView_AfterPerformCallback(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewAfterPerformCallbackEventArgs e)
        {
            if (e.CallbackName == "APPLYFILTER")
            {
                ASPxGridView gv = sender as ASPxGridView;
                gv.JSProperties["cp_FilterApplied"] = "true";
                gv.JSProperties["cp_VisibleRowCount"] = gv.VisibleRowCount;
            }
        }

theGridView.ClientSideEvents.EndCallback = "function(s,e){"theGridView.theGridView_OnEndCallback(s, e);}";

JS:

theGridView_OnEndCallback: function (s, e) {
    if (s.cp_FilterApplied) {
        if (s.cp_FilterApplied.indexOf('true') != -1) {
            this.adjustGridViewSize();/*Uses visible row count.*/
            delete s.cp_FilterApplied;
        }
    }
}

回答1:


  1. In theGridView_AfterPerformCallback add entry to JSProperties collection, e.g. cp_FilterApplied.
  2. Add EndCallback client side event handler.
  3. In EndCallback handler execute this.filterAppliedEvent() if cp_FilterApplied exists.
  4. Delete that property so that subsequent callback doesn't execute filterAppliedEvent method.

Look at my answer to this question for code example. It's really the same problem, just set js property in theGridView_AfterPerformCallback instead of ASPxGridView1_RowUpdated and adjust names/js code to your needs.



来源:https://stackoverflow.com/questions/11803186/client-side-event-that-fires-after-aspxclientgridview-applyfilter-performs-its-w

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!