public IEnumerable SqlDataSource; List<Employees> emp = new List<Employees>(); protected void Page_Load(object sender, EventArgs e) { this.EmployeesGrid.DataSource = emp; this.EmployeesGrid.DataBind(); //this.childData a SQLDataSource defined at the client-end used to retrieve the data in code behind. DataView dv = (DataView)this.childData.Select(DataSourceSelectArguments.Empty); DataTable dt1 = dv.ToTable(); IEnumerable Data = (from DataRow row in dt1.Rows select new Order { OrderID = Convert.ToInt32(row["OrderID"]), CustomerID = row["CustomerID"].ToString(), Freight = Convert.ToDecimal(row["Freight"]), EmployeeID = Convert.ToInt32(row["EmployeeID"]), ShipCity = row["ShipCity"].ToString(), ShipCountry = row["ShipCountry"].ToString() }).ToList(); this.SqlDataSource = Data; } <ej:Grid ID="EmployeesGrid" runat="server" DetailsTemplate="#tabGridContents"> <ClientSideEvents DetailsDataBound="detailGridData" /> . . . . . . . . </ej:Grid> <asp:SqlDataSource id="childData" runat="server" ConnectionString="<%$ ConnectionStrings:SQLConnectionString%>" SelectCommand="SELECT * FROM Orders"> </asp:SqlDataSource> <script id="tabGridContents" type="text/x-jsrender"> . . </script> <script type="text/javascript"> //SqlDataSource a variable defined at the code behind var orderData = JSON.parse('<%= new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(this.SqlDataSource)%>'); function detailGridData(e) { var filteredData = e.data["EmployeeID"]; var data = ej.DataManager(orderData).executeLocal(ej.Query().where("EmployeeID", "equal", parseInt(filteredData), true)); e.detailsElement.find("#detailGrid" + filteredData).ejGrid({ dataSource: data, allowSelection: false, allowPaging: true, . . . . }); e.detailsElement.css("display", ""); e.detailsElement.find("#detailChart" + filteredData).ejChart({ . . . . . }); e.detailsElement.find(".tabcontrol").ejTab({ selectedItemIndex: 1 }); } </script> |
<ej:Grid ID="EmployeesGrid" runat="server" DetailsTemplate="#tabGridContents">
<ClientSideEvents DetailsDataBound="detailGridData" />
. . .
. . .
</ej:Grid>
<asp:SqlDataSource
id="childData"
runat="server"
ConnectionString="<%$ ConnectionStrings:SQLConnectionString%>"
SelectCommand="SELECT * FROM Orders">
</asp:SqlDataSource>
. . . .
. . .
<script id="tabGridContents" type="text/x-jsrender">
<div class="tabcontrol">
<ul>
<li><a rel='nofollow' href="#gridTab1{{:EmployeeID}}">Stock Chart</a>
</li>
<li><a rel='nofollow' href="#gridTab2{{:EmployeeID}}">Stock Grid</a>
</li>
<li><a rel='nofollow' href="#gridTab3{{:EmployeeID}}">Stock Grid</a>
</li>
</ul>
<div id="gridTab1{{:EmployeeID}}">
<div id="detailGrid1{{:EmployeeID}}"></div>
</div>
<div id="gridTab2{{:EmployeeID}}">
<div id="detailGrid2{{:EmployeeID}}"></div>
</div>
<div id="gridTab3{{:EmployeeID}}">
<div id="detailGrid3{{:EmployeeID}}"></div>
</div>
</div>
</script>
<script type="text/javascript">
//SqlDataSource a variable defined at the code behind
var orderData1 = JSON.parse('<%= new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(this.SqlDataSource1)%>');
var orderData2 = JSON.parse('<%= new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(this.SqlDataSource2)%>');
var orderData3 = JSON.parse('<%= new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(this.SqlDataSource3)%>');
function detailGridData(e) {
var filteredData = e.data["EmployeeID"];
var data1 = ej.DataManager(orderData1).executeLocal(ej.Query().where("EmployeeID", "equal", parseInt(filteredData), true));
. . . .
. .
e.detailsElement.find("#detailGrid1" + filteredData).ejGrid({
dataSource: data1,
allowSelection: false,
allowPaging: true,
. . . .
});
e.detailsElement.find("#detailGrid2" + filteredData).ejGrid({
dataSource: data2,
});
e.detailsElement.find("#detailGrid3" + filteredData).ejGrid({
dataSource: data3,
});
e.detailsElement.find(".tabcontrol").ejTab({ selectedItemIndex: 1 });
}
</script> |
public IEnumerable SqlDataSource1;
public IEnumerable SqlDataSource2;
public IEnumerable SqlDataSource3;
List<Employees> emp = new List<Employees>();
List<Orders> order = new List<Orders>();
protected void Page_Load(object sender, EventArgs e)
{
. . .
.. . . .
DataView dv = (DataView)this.childData.Select(DataSourceSelectArguments.Empty);
DataView dv1 = (DataView)this.childData1.Select(DataSourceSelectArguments.Empty);
DataView dv2 = (DataView)this.childData2.Select(DataSourceSelectArguments.Empty);
DataTable dt = dv.ToTable();
DataTable dt1 = dv1.ToTable();
DataTable dt2 = dv2.ToTable();
this.SqlDataSource1 = ToDynamicList(dt);
this.SqlDataSource2 = ToDynamicList(dt1);
this.SqlDataSource3 = ToDynamicList(dt2);
}
public List<dynamic> ToDynamicList(DataTable dt)
{
List<string> cols = (dt.Columns.Cast<DataColumn>()).Select(column => column.ColumnName).ToList();
var dictData = ToDictionary(dt);
return ToDynamicList(dictData, getNewObject(cols, dictData));
}
public List<dynamic> ToDynamicList(List<Dictionary<string, object>> list, Type TypeObj)
{
dynamic temp = new List<dynamic>();
foreach (Dictionary<string, object> step in list)
{
object Obj = Activator.CreateInstance(TypeObj);
PropertyInfo[] properties = Obj.GetType().GetProperties();
Dictionary<string, object> DictList = (Dictionary<string, object>)step;
foreach (KeyValuePair<string, object> keyValuePair in DictList)
{
foreach (PropertyInfo property in properties)
{
if (property.Name == keyValuePair.Key)
{
var convertedValue = keyValuePair.Value == System.DBNull.Value ? null : keyValuePair.Value;
property.SetValue(Obj, convertedValue, null);
break;
}
}
}
temp.Add(Obj);
}
return temp;
}
public List<Dictionary<string, object>> ToDictionary(DataTable dt)
{
var columns = dt.Columns.Cast<DataColumn>();
var Temp = dt.AsEnumerable().Select(dataRow => columns.Select(column =>
new { Column = column.ColumnName, Value = dataRow[column] })
.ToDictionary(data => data.Column, data => data.Value)).ToList();
return Temp.ToList();
}
private Type getNewObject(List<string> list, List<Dictionary<string, object>> dictList)
{ .. .
. . . .
bool flag = true;
if (flag)
{
foreach (Dictionary<string, object> dictStep in dictList)
{
flag = false;
Dictionary<string, object> DictList = (Dictionary<string, object>)dictStep;
foreach (KeyValuePair<string, object> keyValuePair in DictList)
{
var type = keyValuePair.Value.GetType().ToString();
colType.Add(type);
}
}
}
foreach (string step in list)
{
int inx = list.IndexOf(step);
var type = colType[inx];
string propertyName = step;
. . . .
}
Type obj = typeBuilder.CreateType();
return obj;
} |
<ej:Grid ID="EmployeesGrid" runat="server" DetailsTemplate="#tabGridContents">
<ClientSideEvents DetailsDataBound="detailGridData" />
. ..
. .
</ej:Grid>
<script id="tabGridContents" type="text/x-jsrender">
<div class="tabcontrol">
<ul>
<li><a rel='nofollow' href="#gridTab1{{:EmployeeID}}">Stock Chart</a>
</li>
</ul>
<div id="gridTab1{{:EmployeeID}}">
<button id="btn{{:EmployeeID}}"></button>
<div id="detailGrid1{{:EmployeeID}}"></div>
</div>
</div>
</script>
<script type="text/javascript">
//SqlDataSource a variable defined at the code behind
var orderData1 = JSON.parse('<%= new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(this.SqlDataSource1)%>');
function detailGridData(e) {
var filteredData = e.data["EmployeeID"];
var data1 = ej.DataManager(orderData1).executeLocal(ej.Query().where("EmployeeID", "equal", parseInt(filteredData), true));
e.detailsElement.find("#btn" + filteredData).ejButton({
text: "ClickMe"
});
e.detailsElement.find("#detailGrid1" + filteredData).ejGrid({
dataSource: data1,
allowSelection: false,
allowPaging: true,
});
. . .
. . .
e.detailsElement.find(".tabcontrol").ejTab({ selectedItemIndex: 1 });
}
</script> |
<configuration>
<system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength="50000000"/>
</webServices>
</scripting>
</system.web.extensions>
</configuration>
|
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public static object Data(Syncfusion.JavaScript.DataManager value)
{
IEnumerable Data = Data1; //it is a Dynamically created data
DataOperations dp = new DataOperations();
if (value.Where != null)
{
Data = dp.PerformWhereFilter(Data, value.Where, value.Where[0].Condition);
}
int count = Data.AsQueryable().Count();
if (value.Skip != null)
Data = dp.PerformSkip(Data, value.Skip);
if (value.Take != null)
Data = dp.PerformTake(Data, value.Take);
return new { result = Data, count = count };
}
function detailGridData(e) {
var filteredData = e.data["EmployeeID"];
e.detailsElement.find("#btn" + filteredData).ejButton({
text: "ClickMe"
});
e.detailsElement.find("#detailGrid1" + filteredData).ejGrid({
dataSource: ej.DataManager({ url: "Default.aspx/Data", adaptor: new ej.WebMethodAdaptor() }),
query: ej.Query().where("EmployeeID", "equal", parseInt(filteredData), true),
allowPaging: true,
load: function (args) {
this.model.dataSource.dataSource.headers = [];//So define them as array
this.model.dataSource.dataSource.headers.push({ "ID": this._id });//
},
});
. . .
. ..
e.detailsElement.find(".tabcontrol").ejTab({ selectedItemIndex: 1 });
} |
<script type="text/javascript"> //SqlDataSource a variable defined at the code behind var orderData1 = JSON.parse('<%= new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(this.SqlDataSource1)%>'); var data1 = ej.DataManager(orderData1).executeLocal(ej.Query().where("CustomerID", "equal", parseInt(filteredData), true)); function detailGridData(e) { var filteredData = e.data["EmployeeID"]; e.detailsElement.find("#btn" + filteredData).ejButton({ text: "ClickMe" }); e.detailsElement.find("#detailGrid1" + filteredData).ejGrid({ dataSource: data1, . .. }); .. . .. . e.detailsElement.find(".tabcontrol" |