[CLOSED] Convert code from C # ASPX page to extend the GridPanel

  1. #1

    [CLOSED] Convert code from C # ASPX page to extend the GridPanel

    Hi,

    I realize a new class that inherits from GridPanel, IPostBackDataHandler
    to bring basic functionality without requiring to make copiers paste to another page.

    I try to export the code. aspx page in C # code, however I meet difficulties in many cases.

    Class :MyGridPanel.cs

     
    [ToolboxData("<{0}:DDSGridPanel runat=server></{0}:DDSGridPanel>")]
        public class DDSGridPanel : GridPanel, IPostBackDataHandler 
        {
        }

    I have a problem with the click event on menuItem, nothing happens.

    void DDSGridPanel_PreRender(object sender, EventArgs e)
            {
                Ext.Net.MenuItem myMenu = new Ext.Net.MenuItem();
                myMenu.ID = "menuItem10";
                myMenu.Text = "Save state";
                myMenu.DirectEvents.Click.Event += new ComponentDirectEvent.DirectEventHandler(Click_Event);
                Ext.Net.Parameter ExtraParamaters = new Ext.Net.Parameter();
                ExtraParamaters.Name = "order";
                ExtraParamaters.Value = "getOrder()";
                ExtraParamaters.Mode = ParameterMode.Raw;
                ExtraParamaters.Encode = true;
                myMenu.DirectEvents.Click.ExtraParams.Add(ExtraParamaters);
                base.Bin.Add(myMenu);
            }
    method "GetOrder" is written in the class this way :
           protected void GetOrder(object sender, DirectEventArgs e)
           {
               List<Object> order = JSON.Deserialize<List<Object>>(e.ExtraParams["order"]);
               SaveStates(order);
           }

    And it's possible to convert this code in javascript in C# and call it with base.Listeners.BeforeRender.Fn = ?
      var onBeforeRender = function (grid) {
                var view = grid.getView();
    
                view.afterRenderUI = view.afterRenderUI.createSequence(function () {
                    var me = this;
    
                    me.hmenu.add(me.grid.bin);
                });
            };
    I hope this post is well written and clear enough.

    Thank you in advance.
    Last edited by Daniil; Sep 06, 2012 at 12:08 PM. Reason: [CLOSED]
  2. #2
    Hi,

    1. Regarding IPostBackDataHandler.

    The GridPanel class is an inheritor of the PanelBase one. The PanelPase class implements the IXPostBackDataHandler interface. The IXPostBackDataHandler interface is an inheritor of the IPostBackDataHandler one.

    IXPostBackDataHandler
    public interface IXPostBackDataHandler : IPostBackDataHandler
    {
        bool HasLoadPostData { get; set; }
    }
    So, the GridPanel class already implements the IPostBackDataHandler interface. You can remove it from the class definition and just override the respective methods.

    2. Regarding DirectEvent.

    I guess binding a DirectEvent handler within the PreRender event is too late. I would try OnInit or OnLoad.

    Here is the quote from this article.
    http://msdn.microsoft.com/en-us/libr...vs.100%29.aspx

    Be sure that the statement is executed before the event can be raised. Typically, you add handlers during page initialization.
    Also there is the Click_Event handler.
    myMenu.DirectEvents.Click.Event += new ComponentDirectEvent.DirectEventHandler(Click_Event);
    but you demonstrates the GetOrder.
    protected void GetOrder(object sender, DirectEventArgs e)
    By the way, it can look just:
    myMenu.DirectEvents.Click.Event += Click_Event;
    3. Regarding Listeners.

    Example
    string fn = @"function (grid) {
                      var view = grid.getView();
     
                      view.afterRenderUI = view.afterRenderUI.createSequence(function () {
                          var me = this;
     
                          me.hmenu.add(me.grid.bin);
                      });
                  }";
    
    base.Listeners.BeforeRender.Fn = fn;
  3. #3
    Thank you for that explanation, it allowed me to understand the errors

    and everything works.
    Thank you,

    you can mark as solved.

Similar Threads

  1. Replies: 7
    Last Post: Jul 31, 2012, 8:31 PM
  2. Replies: 2
    Last Post: Mar 22, 2012, 12:49 PM
  3. Replies: 0
    Last Post: Dec 01, 2011, 6:43 AM
  4. [CLOSED] Calling a code-behind function from my aspx page
    By Bert76 in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jul 08, 2011, 3:53 PM
  5. Replies: 0
    Last Post: Jun 21, 2011, 2:51 AM

Posting Permissions