Mar 28, 2013, 7:39 AM
[CLOSED] Creating Store and GridPanel Dynamically
Hi there
I am trying to make store and GridPanel Dynamically on Page_Load which is working fine Below is my Code
in the below code i call a "bindstore()" function which builds the store and inside "bindstore()" i call a function "BuildGridPanel()" which builds
columnModel and columns in the gridpanel.
.ASPX
It All Works Fine at the first time but when am trying to rebind every thing on click of a treePanel Node
its not working below is the code of TreeNode Click
.aspx (DirectEvet Tag Inside TreePanel)
Please help
Thanks in advance
I am trying to make store and GridPanel Dynamically on Page_Load which is working fine Below is my Code
in the below code i call a "bindstore()" function which builds the store and inside "bindstore()" i call a function "BuildGridPanel()" which builds
columnModel and columns in the gridpanel.
.ASPX
*<ext:Store ID="strReportViewer" runat="server">
* * * * * * * * </ext:Store>
* * * * * * * * <ext:Container ID="Container1" runat="server" Region="East">
* * * * * * * * * * <Items>
* * * * * * * * * * * * <ext:Panel ID="Panel1" runat="server" Region="West" Title="Reports" Width="1001">
* * * * * * * * * * * * * * <Items>
* * * * * * * * * * * * * * * * <ext:GridPanel ID="gpReportViewer" EnableViewState="true" Width="1000" runat="server">
* * * * * * * * * * * * * * * * </ext:GridPanel>
* * * * * * * * * * * * * * </Items>
* * * * * * * * * * * * </ext:Panel>
* * * * * * * * * * </Items>
* * * * * * * * </ext:Container>
.ASPX.CS
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
bindStore();
}
}
private void bindStore()
{
DataSet dsRecordFindRecord = new DataSet();
DataSet finaldataset = new DataSet();
if (Repid == "" || Repid == null)
{
finaldataset = fn.Selectdata(fn.Selectsinglevalues("select repReportSQL from tc_ReportCatalogue where pk_ReportId = '8'"));
}
else
{
finaldataset = fn.Selectdata(fn.Selectsinglevalues("select repReportSQL from tc_ReportCatalogue where pk_ReportId = '" + Repid + "'"));
}
// Ext.Net.Store Store1 = new Ext.Net.Store();
strReportViewer.DataSource = finaldataset;
//Store1.GroupField = "empLocation";
Ext.Net.Model storereader = new Ext.Net.Model();
//storereader.IDProperty = "empNo";
for (int c = 0; c < finaldataset.Tables[0].Columns.Count; c++)
{
Ext.Net.ModelField rf = new Ext.Net.ModelField();
rf.Name = finaldataset.Tables[0].Columns[c].ColumnName;
storereader.Fields.Add(rf);
}
strReportViewer.Model.Add(storereader);
strReportViewer.DataBind();
BuildGridPanel(finaldataset);
gpReportViewer.Store.Add(strReportViewer);
gpReportViewer.DataBind();
}
public void BuildGridPanel(DataSet ds)
{
gpReportViewer.Width = Unit.Pixel(1000);
gpReportViewer.Height = Unit.Pixel(500);
DataSet dsgetcol = ds;
//////XXXXXXXXXXXXXX///////////
////For Fetching columns display name///
string columns = "";
for (int chk = 0; chk < dsgetcol.Tables[0].Columns.Count; chk++)
{
columns = columns + dsgetcol.Tables[0].Columns[chk].ColumnName + ",";
//gpReportViewer.ColumnModel.Columns.RemoveAt(chk);
}
columns.Remove(columns.Length - 1);
string[] colname = columns.Split(',');
////for adding column model to gridpanel
for (int i = 0; i < ds.Tables[0].Columns.Count; i++)
{
Ext.Net.Column col = new Ext.Net.Column();
col.ID = ds.Tables[0].Columns[i].ColumnName;
col.Text = colname[i];
col.DataIndex = ds.Tables[0].Columns[i].ColumnName;
col.Align = Ext.Net.Alignment.Left;
col.Sortable = true;
//col.Groupable = true;
//col.Lockable = true;
//col.SummaryType = Ext.Net.SummaryType.Average;
gpReportViewer.ColumnModel.Columns.Add(col);
}
}
It All Works Fine at the first time but when am trying to rebind every thing on click of a treePanel Node
its not working below is the code of TreeNode Click
.aspx (DirectEvet Tag Inside TreePanel)
<DirectEvents>
<ItemClick OnEvent="Refresh_Grid" Before="if(!record.data.leaf){return false;};">
<ExtraParams>
<ext:Parameter Name="id" Value="record.data.id" Mode="Raw" />
</ExtraParams>
</ItemClick>
</DirectEvents>
.aspx.cs protected void Refresh_Grid(object sender, DirectEventArgs e)
{
string Id = e.ExtraParams["id"].ToString();
Repid = e.ExtraParams["id"].ToString();
bindStore();
}
Please help
Thanks in advance
Last edited by Daniil; Apr 02, 2013 at 9:27 AM.
Reason: [CLOSED]