[CLOSED] Combobox Direct Event

  1. #1

    [CLOSED] Combobox Direct Event

    Hi,

    I wanna refresh my grid when combobox changed.There are data and colomnCollection in onload method, I wanna refresh them when gridRefresh Method is called by combobox select event. data and colomnCollection uses for creating new grid with new data and new columns.

    But the problem is, event handler is not work when event change, After all operation in onlad method finish, gridrefresh method is work and update data and colomnCollection .

    How can i fix this problem.

    Thanks all
    Onload Method
       protected override void OnLoad(EventArgs e)
            {
    
                CssAdder.AddCss("~/Styles/General.css", this.Page);
    
                #region mainpanel
    
                Panel mainPanel = new Panel
                  {
                      ID = "mainPanel",
                  };
                #endregion
    
    
    
                #region adding child panels to parent panel...
                mainPanel.Add(CreateHeader());
                mainPanel.Add(CreateSearchPanel());
                mainPanel.Add(CreateGrid());
                #endregion
                
                this.Add(mainPanel);
            }
    Create Header Part...
    
    public Panel CreateHeader()
            {
    
                Ext.Net.Panel headerPanel = new Ext.Net.Panel
                      {
                          Title = "Menu",
                          ID = "headerPanel"
                      };
    
                ComboBox cmbMenu = new ComboBox
                {
                    Width = 700,
                    Value = "UserHistory",
                    ID = "cmbMenu",
                    Items = { 
                    new ListItem{
                        Text="Onaylanmış",
                        Value="Approved",
                       
                    },
                    new ListItem{
                        Text="Reddedilmiş",
                        Value="Rejected"
                    },
                   
                    new ListItem{
                        Text="Kullanıcı Geçmişi",
                        Value="UserHistory",
                    },
                    new ListItem{
                        Text="Onay Bekleyenler",
                        Value="PendingApprovel"
                    }
    
                },
                    Listeners =
                        {
                            Select =
                            {
    
                                Handler = " var value=record.data[this.valueField];  State=value; if(value=='UserHistory') {" +
                                          " Ext.getCmp('main_panel').setVisible(true);}" +
                                          "else{  Ext.getCmp('main_panel').setVisible(false);}",
    
                            }
                        }
    
                        ,
                    DirectEvents =
                    {
                        Select =
                        {
                            ExtraParams =
                            { 
                                 new Parameter("cmbMenu","record.data[this.valueField]",ParameterMode.Raw)
                            }
                        }
                    }
                };
    
                
                cmbMenu.DirectEvents.Select.Event += GridRefresh;
    
                headerPanel.Items.Add(cmbMenu);
    
                return headerPanel;
    
            }
    GridRefresh Method

    
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using Ext.Net;
    using Grid;
    
    /// <summary>
    /// Summary description for UserPanelState
    /// </summary>
    /// 
    namespace UserPanelState
    {
        public partial class UserPanelState
        {
            public UserPanelState()
            {
    
               
            }
    
            public void GridRefresh(object sender, DirectEventArgs e)
            {
                string selectedValue = e.ExtraParams["cmbMenu"];
    
                Ext.Net.Panel gridPnl = new Ext.Net.Panel
               {
                   ID = "grid_panel"
               };
    
    
                if (selectedValue == "Approved")
                {               
                    colomnCollection = new Grid.ColumnCollection { "IDID", "Ad", "Soyad", "Telefon", "Firma", "Email", "ToplamSüre" };
                    data = new List<object>
                    {
                        new{IDID="1", Ad="deneme", Soyad="deneme",Telefon="deneme",Firma="deneme",Email="deneme",ToplamSüre="Deneme"},
                    };
                   // this.Add(CreateGrid());
                }
                else
                {
                    colomnCollection = new Grid.ColumnCollection { "ID", "Ad", "Soyad", "Telefon", "Firma", "Email", "ToplamSüre" };
                    data = new List<object>
                    {
                        new{ID="1", Ad="deneme", Soyad="deneme",Telefon="deneme",Firma="deneme",Email="deneme",ToplamSüre="Deneme"},
                    };
    
               //     this.Add(CreateGrid());
    
                }
            }
    
        }
    }
    Last edited by Daniil; Feb 24, 2012 at 12:58 PM. Reason: [CLOSED]
  2. #2
    Hi,

    If you change Columns collection of GridPanel ColumnModel during DirectEvent, you should call its Reconfigure method to cause the changes be affected:
    https://examples1.ext.net/#/GridPane...l/Reconfigure/
    or use the GridPanel AddColumn/RemoveColumn methods (this is also presented in the link above).

    The alternative solution is calling the GridPanel Render method - then all changes in GridPanel will be affected. It is useful if you make many changes during DirectEvent.
    https://examples1.ext.net/#/GridPane...Change_Models/

    The same situation with the Store - use its AddField and RemoveField methods or re-render calling its Render method.

    Hope this helps.
  3. #3
    Thank Danill,

    It's work.

Similar Threads

  1. [CLOSED] Output Cache issue with Direct Method / Direct Event
    By amitpareek in forum 1.x Legacy Premium Help
    Replies: 18
    Last Post: Mar 01, 2013, 5:03 AM
  2. [CLOSED] Event handler before direct event handlers
    By matejgolob in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Jun 08, 2012, 2:31 PM
  3. Direct method and direct event over SSL?
    By dimitar in forum 1.x Help
    Replies: 0
    Last Post: Oct 08, 2011, 8:09 PM
  4. ComboBox stays open after Select Direct Event
    By adamdc78 in forum 1.x Help
    Replies: 2
    Last Post: Sep 24, 2011, 10:01 PM
  5. Replies: 3
    Last Post: Apr 20, 2010, 12:21 PM

Posting Permissions