[CLOSED] Combo box in the gridpanel should not show the value which is selected in the combo box for the next row within GP

  1. #1

    [CLOSED] Combo box in the gridpanel should not show the value which is selected in the combo box for the next row within GP

    Hi

    I have a combo box with in the gridpanel, this combo box is bind by the store.
    when i select the any value in the combo box for the first row, it should not show this value in the combo box for the new row of the grid.
    (eg) if i have values(ID,Phone,Name) and if i select (Phone) in first row within the combo box, in the next row within the combo box i should show only(ID,Name)

    can u please provide me with some example for this.
    Thank you
    Last edited by geoffrey.mcgill; Aug 26, 2011 at 9:14 PM. Reason: [CLOSED]
  2. #2
    Please see the following sample
    <%@ Page Language="C#" AutoEventWireup="True" %>
    <%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>
    
    
    <!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 runat="server">
        <title></title>
        
        <script type="text/javascript">
            function addGroup(grid){
                var o = grid.store.addRecord();
                grid.startEditing(o.index, 0);
            }
            
            function filterGroups(o){
                if(o.field == "Group"){
                    var column = o.grid.getColumnModel().getColumnById("Group"),
                        editor = o.grid.getColumnModel().getCellEditor(o.column, o.row);
                    
                    editor.field.store.filterBy(function(record){
                        var group = record.get("text"),                    
                            index = o.grid.store.findExact("Group", group);
                        return index === -1;
                    });
                }            
            }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
            <ext:ResourceManager runat="server" />
            <ext:GridPanel ID="Grid1" runat="server" 
                ClearEditorFilter="false"
                AutoExpandColumn="Group"
                Title="Grid"
                Width="400"
                Height="250">
                <Store>
                    <ext:Store runat="server">
                        <Reader>
                            <ext:JsonReader>
                                <Fields>
                                    <ext:RecordField Name="Group" />
                                </Fields>
                            </ext:JsonReader>
                        </Reader>
                    </ext:Store>
                </Store>
                
                <ColumnModel>
                    <Columns>
                        <ext:Column ColumnID="Group" Header="Group" DataIndex="Group">
                            <Editor>
                                <ext:ComboBox ID="Combo1" runat="server" ClearFilterOnReset="false">
                                    <Items>
                                        <ext:ListItem Text="ID" />
                                        <ext:ListItem Text="Phone" />
                                        <ext:ListItem Text="Name" />
                                    </Items>
                                </ext:ComboBox>
                            </Editor>
                        </ext:Column>
                    </Columns>
                </ColumnModel>
                
                <TopBar>
                    <ext:Toolbar runat="server">
                        <Items>
                            <ext:Button ID="AddButton" runat="server" Text="Add group">
                                <Listeners>
                                    <Click Handler="addGroup(#{Grid1});" />
                                </Listeners>
                            </ext:Button>
                        </Items>
                    </ext:Toolbar>
                </TopBar>
                
                <Listeners>
                    <AfterEdit Fn="filterGroups" />
                </Listeners>
            </ext:GridPanel>
        </form>
    </body>
    </html>
  3. #3
    Hi, i am usign the below said function
    function FilterGroups(o) {
                debugger;
                if (o.field == "Name") {
                    var column = o.grid.getColumnModel().getColumnById("Name"),
                        editor = o.grid.getColumnModel().getCellEditor(o.column, o.row);
                    editor.field.store.filterBy(function (record) {
                        debugger;
                        var group = record.get("text"),
                            index = o.grid.store.findExact("Name", group);
                        return index === -1;
                    });
                } 
            }
    
    function addGroup() {
                debugger;
                var o = grdCompanyDetailsCompanyCode.store.addRecord();
                grdCompanyDetailsCompanyCode.startEditing(o.index, 0); 
            }
    
    <ext:GridPanel ID="grdCompanyDetailsCompanyCode" runat="server" 
                                        StripeRows="true"  Height="200" AutoExpandColumn="Description" StoreID="CompanyCodeStore"
                                        FieldLabel="Company Codes" AllowBlank="false" IndicatorIcon="BulletRed" AnchorHorizontal="60%">
    <ColumnModel ID="ColumnModel1" runat="server">
                                        <Columns>
                                            <ext:Column Width="100" ColumnID="Name" Header="Code" DataIndex="Name">
                                                <Editor>
                                                    <%--<ext:ComboBox ID="cmbCompanyCode" Disabled="true" runat="server" DisplayField="Name"
                                                        ValueField="Name" StoreID="ComboCompanyCodesStore" AllowBlank="false" Editable="false"
                                                        Mode="Local" ForceSelection="false"  IndicatorIcon="BulletRed"  HiddenName="hdnCodeTypeID"
                                                        ClearFilterOnReset="false">
                                                    </ext:ComboBox>--%>
                                                    <ext:ComboBox ID="cmbCompanyCode" runat="server" ClearFilterOnReset="false">
                                                        <Items>
                                                            <ext:ListItem Text="ID" />
                                                            <ext:ListItem Text="Phone" />
                                                            <ext:ListItem Text="Name" />
                                                        </Items>
                                                    </ext:ComboBox>                                             
                                                </Editor>
                                            </ext:Column>
                                          
                                          <ext:Column Width="200" ColumnID="Description" Header="Value" DataIndex="Description">
                                            <Editor>
                                              <ext:TextField ID="txtCodeDesc" runat="server"  Disabled="true" AllowBlank="false"/>
                                            </Editor>
                                          </ext:Column>   
    
                                        </Columns>
                                      </ColumnModel>
                                      <SelectionModel>
                                        <ext:RowSelectionModel ID="RowSelectionforCompanyCode" runat="server" SingleSelect="true" />
                                      </SelectionModel>
    
                                      <BottomBar>
                                        <ext:Toolbar ID="tbAdd" runat="server" AnchorHorizontal="60%" StyleSpec="background:transparent;border:0px;align:center;">
                                          <Items>
                                            <ext:Label ID="Label2" Text="Double click to edit." runat="server" Enabled="false" />
                                            <ext:ToolbarFill />
                                            <ext:Button runat="server" Text="Add" ID="btnAddCompanyCode" Flat="false" Icon="Add">
                                              <Listeners>
                                                <%--<Click Handler="AddNewCompanyCodes({ Code: '', Description: '' });" />--%>
                                                <Click Handler="addGroup();" />
                                              </Listeners>
                                            </ext:Button>
                                          </Items>
                                        </ext:Toolbar>
                                      </BottomBar>
                                      <View>
                                        <ext:GridView ID="CodeTypeGridView" runat="server" MarkDirty="true" />
                                      </View>
    <Plugins>
                                        <ext:GridFilters runat="server" ID="CompanyCodeFilter">
                                          <Filters>
                                            <ext:StringFilter DataIndex="Code" />
                                            <ext:StringFilter DataIndex="Name" />
                                            <ext:StringFilter DataIndex="Description" />
                                          </Filters>
                                        </ext:GridFilters>
                                      </Plugins>
    <Listeners>
                                        <AfterEdit Fn="FilterGroups" />
                                        <RowDblClick Handler="EditGridPanel(grdCompanyDetailsCompanyCode,rowIndex)" />
                                      </Listeners>
    </ext:GridPanel>
    but still the combo box does not filter,
  4. #4
    You did not define ClearEditorFilter="false" for GridPanel
  5. #5
    This will work if the grid is empty, and if we add a new rows in the grid,
    But i have say value (Name) alredy saved in the grid. so the first row will have Name combo box.
    on adding another row in the grid will display all(ID, Phone, Name).
    where i should only get (ID and Phone)
  6. #6
    Please see modifided sample
    <%@ Page Language="C#" AutoEventWireup="True" %>
    <%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>
     
     
    <!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 runat="server">
        <title></title>
        
        <script runat="server">
            protected void Page_Load(object sender, EventArgs e)
            {
                var store = Grid1.Store.Primary;
                store.DataSource = new System.Collections.Generic.List<object> { 
                    new { Group = "Name"}
                };
                store.DataBind();
            }
        </script>
         
        <script type="text/javascript">
            function addGroup(grid){
                var o = grid.store.addRecord();
                grid.startEditing(o.index, 0);
            }
             
            function filterGroups(o){
                if(o.field == "Group"){
                    var column = o.grid.getColumnModel().getColumnById("Group"),
                        editor = o.grid.getColumnModel().getCellEditor(o.column, o.row);
                     
                    editor.field.store.filterBy(function(record){
                        var group = record.get("text"),                    
                            index = o.grid.store.findExact("Group", group);
                        return index === -1;
                    });
                    
                    editor.field.lastQuery = "";
                }            
            }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
            <ext:ResourceManager runat="server" />
            <ext:GridPanel ID="Grid1" runat="server"
                ClearEditorFilter="false"
                AutoExpandColumn="Group"
                Title="Grid"
                Width="400"
                Height="250">
                <Store>
                    <ext:Store runat="server">
                        <Reader>
                            <ext:JsonReader>
                                <Fields>
                                    <ext:RecordField Name="Group" />
                                </Fields>
                            </ext:JsonReader>
                        </Reader>
                        <Listeners>
                            <Load Handler="filterGroups({field:'Group', grid: #{Grid1}, column: 0, row:0});" Delay="10" />
                        </Listeners>
                    </ext:Store>
                </Store>
                 
                <ColumnModel>
                    <Columns>
                        <ext:Column ColumnID="Group" Header="Group" DataIndex="Group">
                            <Editor>
                                <ext:ComboBox ID="Combo1" runat="server" ClearFilterOnReset="false">
                                    <Items>
                                        <ext:ListItem Text="ID" />
                                        <ext:ListItem Text="Phone" />
                                        <ext:ListItem Text="Name" />
                                    </Items>
                                </ext:ComboBox>
                            </Editor>
                        </ext:Column>
                    </Columns>
                </ColumnModel>
                 
                <TopBar>
                    <ext:Toolbar runat="server">
                        <Items>
                            <ext:Button ID="AddButton" runat="server" Text="Add group">
                                <Listeners>
                                    <Click Handler="addGroup(#{Grid1});" />
                                </Listeners>
                            </ext:Button>
                        </Items>
                    </ext:Toolbar>
                </TopBar>
                 
                <Listeners>
                    <AfterEdit Fn="filterGroups" />
                </Listeners>
            </ext:GridPanel>
        </form>
    </body>
    </html>
  7. #7
    Thank you! u r genius...

Similar Threads

  1. [CLOSED] Combo initialization with no selection on window show.
    By FAS in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Feb 22, 2012, 4:53 PM
  2. [CLOSED] Combo selected text
    By Adrian in forum 2.x Legacy Premium Help
    Replies: 13
    Last Post: Jan 31, 2012, 11:47 PM
  3. [CLOSED] Combo Clearing Selected Text in IE?
    By peter.campbell in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jul 11, 2011, 11:51 AM
  4. Replies: 3
    Last Post: Aug 21, 2010, 5:26 AM
  5. Replies: 1
    Last Post: May 22, 2009, 3:42 PM

Posting Permissions