最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Client side event that fires after ASPxClientGridView.ApplyFilter performs its work - Stack Overflow

programmeradmin2浏览0评论

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

.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 plete. 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;
        }
    }
}

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

http://www.devexpress./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 plete. 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;
        }
    }
}
Share edited Jan 9, 2013 at 16:16 Soenhay asked Aug 3, 2012 at 20:55 SoenhaySoenhay 4,0686 gold badges39 silver badges62 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 3
  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.

发布评论

评论列表(0)

  1. 暂无评论