Gridpanel with combobox, strange behaviour

  1. #1

    Gridpanel with combobox, strange behaviour

    Im using alot of gridpanels with comboboxes in it. But now the comboboxes in the grid works real bad. Its impossible to save a row in the grid that only has one column that is a combobox. even you example https://examples1.ext.net/#/GridPane...SqlDataSource/
    is acting really strange on the combo column. The combo loses its value all the time.
    If you choose a value in the combo the clicks somwhere else the combo goes blank. The system is almost useless with this behaviour.

    Need help with this asap!

    /Mikael
  2. #2

    RE: Gridpanel with combobox, strange behaviour

    Hi,

    Try to set Editable to false for ComboBox. If you still need editable=true then let me know.


  3. #3

    RE: Gridpanel with combobox, strange behaviour

    The strange behaviour related with Editable=true: if editable then it is mean that custom values allow. Unfortunately, any value (if editable=true) need confirm pressing Enter key. Editable=true is default value.

    We will investigate it. May be we set Editable=false by default. The ComboBox still confusing control and we are still working on it.

    Sorry for unconvenience


  4. #4

    RE: Gridpanel with combobox, strange behaviour



    Hi
    Im really sorry, but that does not work for me, I tried the editable=false. this page that I have, I cant insert a new row. I choose from the combo and the click on the save. And the combo goes blank.


    using System;
    using System.Collections;
    using System.Configuration;
    using System.Data;
    using System.Linq;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Xml.Linq;
    using Coolite.Ext.Web;
    using System.Data.SqlClient;
    using System.Text;
    using System.IO;
    
    
    
    public partial class SalesPort_AdminViewsPerGroup : System.Web.UI.Page
    {
    
    
        int intCompanyId;
    
    
    
        protected void SetMessage(string strMessage, int intType)
        {
            //intType 1=error
            if (intType == 1)
                strMessage = "" + strMessage + "";
    
    
            sbBottombar.SetText(strMessage);
        }
    
    
        protected override void OnInit(EventArgs e)
        {
    
    
         
                if(!Ext.IsAjaxRequest)
                    LoadData();
    
    
            
    
    
        }
    
    
        private void LoadData()
        {
            
    
    
            string sConnString = System.Configuration.ConfigurationManager.AppSettings.Get("TravelPerfectConnectionString");
            SqlConnection DBConnect = new SqlConnection();
            DBConnect.ConnectionString = sConnString;
            try
            {
                DBConnect.Open();
    
    
                SqlCommand LasData = new SqlCommand("", DBConnect);
    
    
                LasData.CommandText = "SELECT *, " +
                                      "Case " +
                                          "When UserGroups.InvertedSecurity = 1 then 'Exclude selected views' " +
                                          "Else 'Include selected views'" + 
                                      "End Security " + 
                                      "FROM UserGroups";                                  
                SqlDataReader DataReader = LasData.ExecuteReader();
                while (DataReader.Read())
                {
                    cbUserGroups.Items.Add(new Coolite.Ext.Web.ListItem(DataReader["GroupName"].ToString() + " - " + DataReader["Security"], DataReader["GroupId"].ToString()));
                }
                DataReader.Close();
    
    
                if (cbUserGroups.Items.Count <= 0)                        
                    cbUserGroups.Items.Add(new Coolite.Ext.Web.ListItem("Empty", "0"));
                cbUserGroups.SelectedItem.Value = cbUserGroups.Items[0].Value;
                cbUserGroups.SelectedItem.Text = cbUserGroups.Items[0].Text;
    
    
                //Filenames
                LasData.CommandText = "SELECT Filename, Name " +
                                      "FROM Views";
                DataReader = LasData.ExecuteReader();
                while (DataReader.Read())
                {
                    cbFiles.Items.Add(new Coolite.Ext.Web.ListItem(DataReader["Name"].ToString(), DataReader["Filename"].ToString()));
                }
                DataReader.Close();
                //--
            }
            catch (Exception err)
            {
                SetMessage("Could not load user groups: "+err.Message, 1);
            }
            finally
            {
                DBConnect.Close();
            }
        }
    
    
        protected void ChangeGroup(object sender, AjaxEventArgs e)
        {
            gpViewsPerGroup.AddScript("#{gpViewsPerGroup}.reload();");
        }
    
    
        protected void Page_Load(object sender, EventArgs e)
        {
            SqlDSViewsPerGroup.InsertCommand = "INSERT INTO ViewsPerGroup " +
                                               "(GroupId, " +
                                               "Filename) " +
                                               "VALUES " +
                                               "(" + cbUserGroups.SelectedItem.Value + ", " +
                                               "@ViewName)";
    
    
            SqlDSViewsPerGroup.SelectCommand = "Select Views.Name as 'ViewName', ViewsPerGroup.GroupId as 'GroupId', "+
                                               "ViewsPerGroup.Filename as 'FileName', MenuItems.MenuId as 'MenuId', " +
                                               "CAST(ViewsPerGroup.GroupId as varchar)+'-'+RTRIM(ViewsPerGroup.Filename) as 'Id' " +
                                               "from ViewsPerGroup "+
                                               "Left join Views on "+
                                               "ViewsPerGroup.Filename = Views.Filename " +
                                               "Left join MenuItems on " +
                                               "Views.MenuId = MenuItems.MenuId " +
                                               "Where GroupId = '" + cbUserGroups.SelectedItem.Value + "' Order By Views.MenuId";
    
    
            SqlDSViewsPerGroup.UpdateCommand = "UPDATE ViewsPerGroup SET Filename = @ViewName WHERE GroupId = @GroupId and Filename = @Filename";
    
    
            SqlDSViewsPerGroup.DeleteCommand = "DELETE FROM ViewsPerGroup WHERE ((CAST(ViewsPerGroup.GroupId as varchar) + '-' + RTRIM(ViewsPerGroup.Filename)) = @Id)";
    
    
    
            gpViewsPerGroup.Title = "Views for " + cbUserGroups.SelectedItem.Text + " group";
                               
        }
    
    
        protected void Store1_RefershData(object sender, StoreRefreshDataEventArgs e)
        {
            this.Store1.DataBind();
        }
    
    
    }

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="AdminViewsPerGroup.aspx.cs" Inherits="AdminViewsPerGroup" %>
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
    <%@ OutputCache Location="None" %> 
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title></title>
    
    
        <script src="Js/GeneralFunctions.js" type="text/javascript"></script>
        <script type="text/javascript">                       
        </script>
    
    
    </head>
    <body>
        <form id="form2" runat="server">
         <ext:ScriptManager ID="ScriptManager1" runat="server">
        </ext:ScriptManager>
        
        <asp:SqlDataSource ID="SqlDSViewsPerGroup" runat="server"  ConnectionString="<%$ ConnectionStrings:TravelPerfectConnectionString %>"
        >  
                     
            <UpdateParameters>            
                <asp:Parameter Name="GroupId" Type="Int32" />
                <asp:Parameter Name="Filename" Type="String" />
            </UpdateParameters>
            
        </asp:SqlDataSource>
         
        <ext:Store ID="Store1" runat="server" 
            DataSourceID="SqlDSViewsPerGroup"
            OnRefreshData="Store1_RefershData"
            RefreshAfterSaving="Always"
            >
    
    
            <Reader>            
                <ext:JsonReader ReaderID="Id">
                    <Fields>
                        <ext:RecordField Name="Id" Type="String" />
                        <ext:RecordField Name="GroupId" Type="Int" />
                        <ext:RecordField Name="ViewName" Type="String" />
                        <ext:RecordField Name="FileName" Type="String" />
                        <ext:RecordField Name="MenuId" Type="String" />
                        
                        
                        
                    </Fields>
                </ext:JsonReader>
            </Reader>
        </ext:Store>        
        
             
         
        <ext:ViewPort ID="ViewPort1" runat="server">
            <Body>
                <ext:BorderLayout ID="BorderLayout1" runat="server">
                    <Center Collapsible="false" Split="true">
                        <ext:Panel ID="pnlBody" runat="server" Header="false" Border="false" BodyStyle="padding:4px;">
                            <Body>
                                <ext:Panel ID="pnlHeader" runat="server" Header="false" Border="false">
                                    <Body>
                                    <ext:FormLayout ID="FormLayout1" runat="server" >
                                        <ext:Anchor>
                                            <ext:ComboBox Width="200" runat="server" FieldLabel="User group" ReadOnly="true" Editable="false" ID="cbUserGroups">
                                            <AjaxEvents><Select OnEvent="ChangeGroup"></Select></AjaxEvents>
                                            </ext:ComboBox>
                                        </ext:Anchor>
                                    </ext:FormLayout>
                                    </Body>
                                </ext:Panel>                                
    
    
                                <br />
                                
                                <ext:GridPanel 
                                runat="server" 
                                ID="gpViewsPerGroup" 
                                Title="Views"
                                AutoHeight="true"
                                StoreID="Store1" Floating="true" Border="true" BodyBorder="true" Header="true"  >
                                <ColumnModel ID="ColumnModel1" runat="server">
                                <Columns>
                                    
                                    <ext:Column DataIndex="ViewName" Header="View name"  Width="150">
                                        <Editor>
                                            <ext:ComboBox ID="cbFiles" ReadOnly="true" runat="server" />
                                        </Editor>                                
                                    </ext:Column>
                                    <ext:Column DataIndex="MenuId" Header="Menu item"  Width="150">
                                    </ext:Column>
                                    
                                    
                                </Columns>
                                </ColumnModel>  
                                  
                                <SelectionModel>
                                    <ext:RowSelectionModel ></ext:RowSelectionModel>
                                </SelectionModel>
                                
                                <Buttons>
                                    <ext:Button ID="btnSave" runat="server"  Text="Save" Icon="Disk">
                                        <Listeners>
                                            <Click Handler="#{gpViewsPerGroup}.save();" />
                                        </Listeners>
                                    </ext:Button>                            
                                    <ext:Button ID="btnInsert" runat="server"  Text="Insert" Icon="Add">
                                        <Listeners>
                                            <Click Handler="#{gpViewsPerGroup}.insertRecord(0, {});#{gpViewsPerGroup}.getView().focusRow(0);#{gpViewsPerGroup}.startEditing(0, 0);" />
                                        </Listeners>
                                    </ext:Button>
                                    <ext:Button ID="btnDelete" runat="server"  Text="Delete" Icon="Delete">
                                        <Listeners>
                                            <Click Handler="#{gpViewsPerGroup}.deleteSelected();#{gpViewsPerGroup}.save();" />
                                        </Listeners>
                                    </ext:Button>                                
                                
                                </Buttons>
                                <BottomBar>
                                    <ext:PagingToolBar ID="PagingToolBar1" runat="server" PageSize="10" StoreID="Store1" DisplayInfo="false" />
                                </BottomBar>                            
    
    
                                </ext:GridPanel>
    
    
                            </Body>                     
                        </ext:Panel>
                    </Center>
                    <South>
    
    
                        <ext:StatusBar 
                        ID="sbBottombar" 
                        runat="server"  
                        DefaultText="">
                        <Items>                    
                        </Items>
                        </ext:StatusBar>    
                    </South>
                </ext:BorderLayout>     
                   
            </Body>
        </ext:ViewPort>
        </form>
    </body>
    </html

    /Mikael
  5. #5

    RE: Gridpanel with combobox, strange behaviour

    I noticed on one of my pages that uses a gridpanel and a combobox, I get null reference value on the this hidden field in coolite.axd. This is when I choose a value in the combo and then clicks outside the combo.

    if (!Ext.isEmpty(this.selValue) &amp;&amp; this.selText != t &amp;&amp; this.selValue == this.getValue()) {
        this.hiddenField.value = ""; <--error
    }
    /Mikael
  6. #6

    RE: Gridpanel with combobox, strange behaviour

    Hi Mikael,

    Please update from the SVN. I disabled ability to input custom values to a combo in the grid while. We will try to stable it later.

    Please let me know about result


  7. #7

    RE: Gridpanel with combobox, strange behaviour

    Thanks, all erros dissapeard. Great!

    /Mikael

Similar Threads

  1. Strange behaviour in markup
    By Paul D in forum 1.x Help
    Replies: 1
    Last Post: Nov 09, 2010, 12:27 PM
  2. Replies: 0
    Last Post: Feb 01, 2010, 5:44 AM
  3. [CLOSED] Strange behaviour of ComboBox in Grid Toolbar
    By macap in forum 1.x Legacy Premium Help
    Replies: 10
    Last Post: Sep 01, 2009, 6:45 AM
  4. Replies: 7
    Last Post: May 09, 2009, 8:06 AM
  5. [CLOSED] strange ComboBox behaviour
    By alexp in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: May 01, 2009, 10:13 AM

Posting Permissions