CheckboxSelectionModel and ColumnModel issues

  1. #1

    CheckboxSelectionModel and ColumnModel issues

    I have a simple gridPanel in a control that displays a single data field and a TemplateColumn with two radio buttons.

    The goal is to process all rows selected. During that processing, different stuff is done based on the radio button selection.

    There are two issues here.

    First: I have found numerous examples on how to use checkBoxSelectionModel, but it doesn't work. I always get all rows returned when the grid is submitted. All the examples are using RowSelectSelectionModel, but this doesn't work either.

    This is what I am using to get the data: Ext.encode(#{gpnlCards}.getRowsValues(true))
    Regardless of weather I use true or false in the parm, I always get all rows from the grid.

    Second: I have found how to get to the DataSource behind the grid, and its data, but no examples of how to access the TemplateColumn in the grid itself. Can someone point me to an example or explanation of how this works?

    <%@ Control Language="C#"  %>
    <%@ Import Namespace="System.Collections.Generic" %>
    
    <script runat="server">
        [DirectMethod]
        protected void btnSubmit_Click(object sender, DirectEventArgs e)
        {             
            
            string json = e.ExtraParams["Values"];
            
            //XML representation
            XmlNode gridXml = JSON.DeserializeXmlNode("{records:{record:" + json + "}}");
    
            //array of Dictionaries
            Dictionary<string, string>[] gridData = JSON.Deserialize<Dictionary<string, string>[]>(json);
    
    
            foreach (Dictionary<string, string> row in gridData)
            {
                foreach (KeyValuePair<string, string> keyValuePair in row)
                {
                    //Do stuff with the data here
                }
    
            };
    
            X.Msg.Show(new MessageBoxConfig
            {
                Title = "Request Processed",
                Message = "Card(s) have been deactiviated.",
                Buttons = MessageBox.Button.OK,
                Icon = MessageBox.Icon.INFO
            });
    
            BindData();
    
        }
    
    
    </script>
    
    <ext:ResourceManagerProxy ID="resourceManagerProxy" runat="server" />
    
    <ext:Store ID="sCards" runat="server">
        <Reader>
            <ext:JsonReader IDProperty="TbCardID">
                <Fields>
                    <ext:RecordField Name="TbCardID" Type="Int"/>
            <ext:RecordField Name="CardNumber" Type="String" />
                    <ext:RecordField Name="CardType" Type="Int" />
                    <ext:RecordField Name="Is_Deleted" Type="Boolean" />
                    <ext:RecordField Name="Created_By" Type="Int" />
                    <ext:RecordField Name="Created_On" Type="Date" />
                    <ext:RecordField Name="Modified_By" Type="Int" />
                    <ext:RecordField Name="Modified_On" Type="Date" />            
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>

    ...some code removed for brevity

                        <ext:GridPanel 
                            ID="gpnlCards" 
                            StoreID="sBenefitCards" 
                            Collapsible="false" 
                            StripeRows="false"
                            TrackMouseOver="true" 
                            AutoWidth="true" 
                            Height="225" 
                            AutoScroll="true" 
                            MonitorResize="true"
                            AutoShow="true"
                            runat="server" >
                            <ColumnModel ID="ColumnModel2" runat="server">
                                <Columns>
                                    <ext:Column ColumnID="CardNumber" Width="150" Sortable="true" DataIndex="CardNumber" />
                                    <ext:TemplateColumn>
                                        <Template runat="server">
                                            <Html>
                                                <input type="radio" name="sendReplacement" value="Yes">Yes</input>
                                                <input type="radio" name="sendReplacement" value="No">No</input>
                                            </Html>
                                        </Template>
                                    </ext:TemplateColumn>
                                </Columns>
                            </ColumnModel>
                            <SelectionModel>
                                <ext:CheckboxSelectionModel runat="server" ID="csmCards" />                            
                            </SelectionModel>
                            
                            <View>
                                <ext:GridView ID="GridView1" AutoFill="true" ForceFit="true" runat="server"></ext:GridView>
                            </View>
                        </ext:GridPanel>
                    </ext:LayoutRow>
                </Rows>
            </ext:RowLayout>
        </Content>
        <Buttons>
            <ext:Button ID="btnSubmit" Text="Submit" Disabled="true" Icon="Disk" runat="server">
                <DirectEvents>
                    <Click OnEvent="btnSubmit_Click">
                        <EventMask ShowMask="true" MinDelay="500" />
                        <ExtraParams>
                            <ext:Parameter Name="Values" Value="Ext.encode(#{gpnlCards}.getRowsValues(true))" Mode="Raw" />
                        </ExtraParams>
                    </Click>
                </DirectEvents>
            </ext:Button>
            
        </Buttons>
     </ext:Panel>
  2. #2

    RE: CheckboxSelectionModel and ColumnModel issues

    Hi,

    If you use 1.0 version then

    Ext.encode(#{GridPanel1}.getRowsValues({selectedOnly:true}))
    Do not use html inputs inside temple column because there is no way to retrieve information from them (well, it is possible to retrieve its values but it is requires some js code). But template column is used for custom repsentation of the data only

  3. #3

    RE: CheckboxSelectionModel and ColumnModel issues

    Thanks Vladimir, that worked. I though we were on a later version.

    I also figured out how to setup the columns properly to have access to them.




Similar Threads

  1. [CLOSED] about ColumnModel.cs
    By CPA1158139 in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Sep 27, 2012, 2:55 PM
  2. [CLOSED] [1.0] bug - columnmodel defaultwidth
    By brettmas in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Mar 05, 2010, 7:09 AM
  3. Replies: 1
    Last Post: Sep 04, 2009, 9:14 AM
  4. [CLOSED] Localization of ColumnModel
    By drgw74 in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jun 22, 2009, 10:40 AM
  5. Add ColumnModel to GridPanel
    By aalkema in forum 1.x Help
    Replies: 0
    Last Post: Apr 27, 2009, 11:58 AM

Posting Permissions