Jan 25, 2017, 1:49 PM
[OPEN] [#1424] [4.2.0] Selection issue on Childgrid in rowExpander
Hi Guys
I have grid and a nested childgrid with CheckboxSelectionModel in both parent and childgrid , when i select parent grid row all the child grid row gets selected as well . This selection is not shown in selectionmodel() of the childgrid . So when i try to clear i cant clear them
What i need is prevent selection of childgrid items on selecting parent grid row
My Grid Code is below
c# code below
Amit
I have grid and a nested childgrid with CheckboxSelectionModel in both parent and childgrid , when i select parent grid row all the child grid row gets selected as well . This selection is not shown in selectionmodel() of the childgrid . So when i try to clear i cant clear them
What i need is prevent selection of childgrid items on selecting parent grid row
My Grid Code is below
<%@ page language="C#" autoeventwireup="true" codefile="Default.aspx.cs" inherits="_Default" %>
<%@ register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript">
var template = '<span style="color:{0};">{1}</span>';
var change = function (value) {
return String.format(template, (value > 0) ? "green" : "red", value);
};
var pctChange = function (value) {
return String.format(template, (value > 0) ? "green" : "red", value + "%");
};
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<ext:resourcemanager id="ResourceManager1" runat="server" cleanresourceurl="true" directmethodnamespace="DM" namespace="app">
</ext:resourcemanager>
<ext:viewport runat="server">
<Items>
<ext:GridPanel
ID="GridPanel1"
runat="server"
Title="Array Grid"
Width="700" AutoHeight="true">
<Store>
<ext:Store ID="Store1" runat="server" OnReadData="MyData_Refresh" PageSize="10">
<Reader>
<ext:ArrayReader>
<Fields>
<ext:RecordField Name="company" />
<ext:RecordField Name="price" Type="Float" />
<ext:RecordField Name="change" Type="Float" />
<ext:RecordField Name="pctChange" Type="Float" />
<ext:RecordField Name="lastChange" Type="Date" DateFormat="M/d hh:mmtt" />
</Fields>
</ext:ArrayReader>
</Reader>
</ext:Store>
</Store>
<columnmodel runat="server">
<Columns>
<ext:Column ColumnID="Company" Header="Company" DataIndex="company" />
<ext:Column Header="Price" DataIndex="price">
<Renderer Format="UsMoney" />
</ext:Column>
<ext:Column ColumnID="Change" Header="Change" DataIndex="change">
<Renderer Fn="change" />
</ext:Column>
<ext:Column Header="Change" DataIndex="pctChange">
<Renderer Fn="pctChange" />
</ext:Column>
<ext:DateColumn Header="Last Updated" DataIndex="lastChange" />
</Columns>
</columnmodel>
<SelectionModel>
<ext:CheckboxSelectionModel runat="server"></ext:CheckboxSelectionModel>
</SelectionModel>
<View>
<ext:GridView runat="server" StripeRows="true" />
</View>
<plugins>
<ext:RowExpander ID="gridResultsExpander" Visible="true" runat="server" ExpandOnDblClick="false">
<Component>
<ext:GridPanel
ID="gridChild1"
runat="server"
Width="500" AutoHeight="true" EnableColumnHide="false">
<Store>
<ext:Store ID="Store2" runat="server" OnReadData="MyChildData_Refresh" PageSize="10">
<Reader>
<ext:ArrayReader>
<Fields>
<ext:RecordField Name="company" />
<ext:RecordField Name="price" Type="Float" />
</Fields>
</ext:ArrayReader>
</Reader>
</ext:Store>
</Store>
<columnmodel runat="server">
<Columns>
<ext:Column ColumnID="Company" Header="Company" DataIndex="company" />
<ext:Column Header="Price" DataIndex="price">
<Renderer Format="UsMoney" />
</ext:Column>
</Columns>
</columnmodel>
<SelectionModel>
<ext:CheckboxSelectionModel runat="server" XCheckOnly="true" PruneRemoved="false" ShowHeaderCheckbox="false" CheckOnly="true"
></ext:CheckboxSelectionModel>
</SelectionModel>
</ext:GridPanel>
</Component>
</ext:RowExpander>
</plugins>
</ext:GridPanel>
</Items>
</ext:viewport>
</div>
</form>
</body>
</html>
c# code below
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Ext.Net;
public partial class _Default : System.Web.UI.Page{
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
this.Store1.DataSource = this.Data;
this.Store1.DataBind();
this.Store2.DataSource = this.Data2;
this.Store2.DataBind();
}
}
protected void MyData_Refresh(object sender, StoreRefreshDataEventArgs e)
{
this.BindData();
}
protected void MyChildData_Refresh(object sender, StoreRefreshDataEventArgs e)
{
this.BindChildData();
}
private void BindData()
{
Store store = this.GridPanel1.GetStore();
store.DataSource = this.Data;
store.DataBind();
}
private void BindChildData()
{
Store store = this.gridChild1.GetStore();
store.DataSource = this.Data2;
store.DataBind();
}
private object[] Data
{
get
{
DateTime now = DateTime.Now;
return new object[]
{
new object[] { "3m Co", 71.72, 0.02, 0.03, now },
new object[] { "Alcoa Inc", 29.01, 0.42, 1.47, now },
new object[] { "Altria Group Inc", 83.81, 0.28, 0.34, now },
new object[] { "American Express Company", 52.55, 0.01, 0.02, now },
new object[] { "American International Group, Inc.", 64.13, 0.31, 0.49, now },
new object[] { "AT&T Inc.", 31.61, -0.48, -1.54, now },
new object[] { "Boeing Co.", 75.43, 0.53, 0.71, now },
new object[] { "Caterpillar Inc.", 67.27, 0.92, 1.39, now },
new object[] { "Citigroup, Inc.", 49.37, 0.02, 0.04, now },
new object[] { "E.I. du Pont de Nemours and Company", 40.48, 0.51, 1.28, now },
new object[] { "Exxon Mobil Corp", 68.1, -0.43, -0.64, now },
new object[] { "General Electric Company", 34.14, -0.08, -0.23, now },
new object[] { "General Motors Corporation", 30.27, 1.09, 3.74, now },
new object[] { "Hewlett-Packard Co.", 36.53, -0.03, -0.08, now }
};
}
}
private object[] Data2
{
get
{
DateTime now = DateTime.Now;
return new object[]
{
new object[] { "Wipro", 71.72,now },
new object[] { "Infosys", 29.01, 1.47, now },
new object[] { "Wal-Mart Stores, Inc.", 45.45, now }
};
}
}
}
Thanks Amit
Last edited by fabricio.murta; Jan 27, 2017 at 5:57 PM.