Jan 27, 2010, 3:25 PM
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?
...some code removed for brevity
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>