CellSelection and database

Page 1 of 4 123 ... LastLast
  1. #1

    CellSelection and database

    Hi,

    i need to pass data from cellselection in a gridpanel to another gridpanel.
    The only way I find is to pass with RowIndex and it works if I don' change order in first gridpanel. but if I change this order the row index is wrong.

            
    CellSelectionModel cell = new CellSelectionModel();
    cell = this.GridPubbliche.SelectionModel.Primary as CellSelectionModel;
    int row;
    row = Convert.ToInt32(cell.SelectedCell.RowIndex.ToString());
    this.RowSelectionModel1.SelectRow(row);
    So I need to pass by key, a field in my database. How can I pass data from database in cellselectionmodel?
  2. #2
    I'm lookinf for something like this https://examples1.ext.net/#/GridPane...s/One-to-Many/
    But when I click on a cell (or on a row) I want the corresponding row in the other grid to be selected.
    http://i.imgur.com/tRVlW.png
    Last edited by bolzi89; Dec 19, 2011 at 8:01 AM.
  3. #3
    Hi,

    Please use the CellSelectionModel CellSelect event.
    http://docs.sencha.com/ext-js/3-4/#!...ent-cellselect
  4. #4
    Hi, thanks for the reply.
    But I can't use CellSelect, i've to use property from DB, something like this, but it doesn't work...

            CellSelectionModel cell = new CellSelectionModel();
            cell = this.GridPubbliche.SelectionModel.Primary as CellSelectionModel;
            string key = cell.SelectedCell.RecordID.ToString();
            this.RowSelectionModel1.SelectById(key);
            this.RowSelectionModel1.UpdateSelection();
  5. #5
    Where do you call this code?

    Please provide a full, but simplified, sample to reproduce the problem.
  6. #6
    Here you are. I've tried to debug this code and string key have correct value, but RowSelection doesn't work.

    Aspx code

                                <ext:GridPanel 
                                    ID="GridPubbliche" 
                                    runat="server"  
                                    Title="Opere pubbliche"                              
                                    Icon="foldergo"
                                    StripeRows="true"
                                    Collapsible="true"
                                    EnableColumnMove="true" Width="300"
        
                                    >
                                    <Store>
                                    
                                    <ext:Store ID="StoreMenuGrid" runat="server">
                                        <Reader>
                                            <ext:JsonReader IDProperty="KEY">
                                                <Fields>
                                                    <ext:RecordField Name="KEY" />
                                                    <ext:RecordField Name="TITLE" />
                                                    <ext:RecordField Name="FATHER" />
                                                    <ext:RecordField Name="DESCRIPTION" />
                                                </Fields>
                                            </ext:JsonReader>
                                        </Reader>
                                    </ext:Store>
    
                                    
                                    </Store>
                                    <ColumnModel ID="ColumnModel2" runat="server">
    		                            <Columns>
    		                                <ext:Column ColumnId="TITLE" Width="294" DataIndex="TITLE" MenuDisabled="true" Sortable="false" />
                                            </Columns>
                                    </ColumnModel>
    
                                   <SelectionModel>
                                        <ext:CellSelectionModel runat="server">
                                            <DirectEvents>
                                                <CellSelect OnEvent="Cell_Click" />                        
                                            </DirectEvents>
                                        </ext:CellSelectionModel>
                                    </SelectionModel>
    
                                    </ext:GridPanel>
                                    
                                
                    </West>
                    
                    <Center>
           
                            <ext:GridPanel ID="GridPanelPubbliche" 
                                runat="server" 
                                Frame="true" 
                                Height="600">
                                <Store>
                                    <ext:Store ID="StorePanelGrid" runat="server">
                                        <Reader>
                                            <ext:JsonReader IDProperty="KEY">
                                                <Fields>
                                                    <ext:RecordField Name="KEY" />
                                                    <ext:RecordField Name="TITLE" />
                                                    <ext:RecordField Name="FATHER" />
                                                    <ext:RecordField Name="DESCRIPTION" />
                                                </Fields>
                                            </ext:JsonReader>
                                        </Reader>
                                    </ext:Store>
                                </Store>
                                <ColumnModel ID="ColumnModel1" runat="server">
                                    <Columns>
                                        <ext:Column DataIndex="KEY" Header="Key" Width="150"  />
                                        <ext:Column DataIndex="TITLE" Header="Title" Width="150" />
                                        <ext:Column DataIndex="FATHER" Header="Father" Width="150" />
                                        <ext:Column DataIndex="DESCRIPTION" Header="Description" Width="150" Resizable="true" />
                                    </Columns>
                                </ColumnModel>
                 
                                <SelectionModel>
                                    <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" />
                                </SelectionModel>
                            </ext:GridPanel>
    Cs code

    
        protected void Page_Load(object sender, EventArgs e)
        {
            ActionPlanList apList = new ActionPlanList();
    
            dprogetti = (DataSet)apList.list(-10);
            dpubbliche = (DataSet)apList.list(-11);
            dgestionali = (DataSet)apList.list(-16);
         
            this.StoreMenuGrid.DataSource = dpubbliche;
            this.StoreMenuGrid.DataBind();
            
            ActionPlanList apGrid = new ActionPlanList();
            DataSet dsGrid;
            dsGrid = (DataSet)apGrid.list(-11);
            this.StorePanelGrid.DataSource = dsGrid;
            this.StorePanelGrid.DataBind();
    
        }
    
    
        protected void Cell_Click(object sender, DirectEventArgs e)
        {
    
            CellSelectionModel cell = new CellSelectionModel();
            cell = this.GridPubbliche.SelectionModel.Primary as CellSelectionModel;
            string key = cell.SelectedCell.RecordID.ToString();
            this.RowSelectionModel1.SelectById(key);
            this.RowSelectionModel1.UpdateSelection();     
        }
  7. #7
    If a key is really correct, then removing this line
    this.RowSelectionModel1.UpdateSelection();
    should solve the problem.
  8. #8
    Same problem... I click on a cell in west grid, but corresponding row in center grid isn't selected...
  9. #9
    Please post a response of Cell_Click.
  10. #10
    I solved. I've to change string key to int key. I'm so stupid...
    However thanks for help and your patience Daniil ^^
    Last edited by bolzi89; Dec 19, 2011 at 10:21 AM.
Page 1 of 4 123 ... LastLast

Similar Threads

  1. GridPanel CellSelection - multi?
    By ocr in forum 2.x Help
    Replies: 6
    Last Post: May 15, 2015, 4:54 PM
  2. Call JavaScript function with CellSelection
    By bolzi89 in forum 1.x Help
    Replies: 5
    Last Post: Dec 23, 2011, 2:42 PM
  3. Replies: 5
    Last Post: Jul 30, 2011, 6:40 PM
  4. CheckboxGroup example with database
    By reinout.mechant@imprss.be in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Mar 18, 2010, 11:01 AM
  5. Save in database
    By flaviodamaia in forum 1.x Help
    Replies: 4
    Last Post: Nov 06, 2008, 7:16 AM

Posting Permissions