Hi
I've been struggling WebHierarchicalDataGrid. I load rows on demand. For first expanding, grid successfully expands row but if I try to expand another row, nothing happens. In debug, for first click page enters page load, executes filling method and handles event and filling demand data. But for second, it does not enter page load. After that if click another row it expands successfully but if I try to expand non expanded rows again, There is nothing. I'm sure about all rows successfully filled. Here is my code.
private void MesajDoldur() { DataTable dtMessages = new DataTable(); DataSet dsKullanici = new DataSet(); DataTable dtKullanici = new DataTable(); Messages = new clsMessages(); dsKullanici = Messages.KisiGetir(RezervasyonRef, 0, 1); dtKullanici = dsKullanici.Tables[0]; dtKullanici.TableName = "tableKisi"; Infragistics.Web.UI.DataSourceControls.DataView dvKisi = new Infragistics.Web.UI.DataSourceControls.DataView(); dvKisi.ID = "vBaslik"; dvKisi.DataMember = "tableKisi"; dvKisi.DataSource = dtKullanici;
dtMessages.TableName = "tableMesaj"; dtMessages.Columns.Add("ID", typeof(int)); dtMessages.Columns.Add("Mesaj", typeof(string)); for (int i = 0; i < dtKullanici.Rows.Count; i++) { DataRow drMessage = dtMessages.NewRow(); drMessage[0] = Convert.ToInt32(dtKullanici.Rows[i][0]); drMessage[1] = " "; dtMessages.Rows.Add(drMessage); }
#region comment dvMesaj Infragistics.Web.UI.DataSourceControls.DataView dvMesaj = new Infragistics.Web.UI.DataSourceControls.DataView();
dvMesaj.ID = "vMesaj"; dvMesaj.DataMember = "tableMesaj";
dvMesaj.DataSource = dtMessages;
whdsShowMessages.DataRelations.Clear(); whdsShowMessages.DataViews.Clear(); whgridShowMessages.Rows.Clear();
whdsShowMessages.DataViews.Add(dvKisi); whdsShowMessages.DataViews.Add(dvMesaj);
Infragistics.Web.UI.DataSourceControls.DataRelation drel = new Infragistics.Web.UI.DataSourceControls.DataRelation("vBaslik", "ID", "vMesaj", "ID"); whdsShowMessages.DataRelations.Add(drel); #endregion whgridShowMessages.DataSource = whdsShowMessages; whgridShowMessages.DataBind();
}
protected void whgridShowMessages_RowIslandsPopulating(object sender, Infragistics.Web.UI.GridControls.ContainerRowCancelEventArgs e) {
e.Cancel = true; Messages = new clsMessages(); DataSet dsChild = new DataSet(); dsChild = Messages.MesajGetir(RezervasyonRef, Convert.ToInt32(e.Row.DataKey[0]), 1);
ContainerGrid childGrid = new ContainerGrid(); e.Row.RowIslands.Add(childGrid);
childGrid.ShowHeader = false; childGrid.DataSource = dsChild;
childGrid.DataBind();
Hi,
Thank you for using our forum.
Is the function MesajDoldur is called for every postback?
You have to assign the data source only when the page is not on a post back (first time when the page is loaded).
Can you send me small sample with the issue?
You can see our sample for manual load on demand:
http://es.infragistics.com/samples/aspnet/hierarchical-data-grid/manual-load-on-demand
Please let me know if I can provide any further assistance.
Before you write your solution I've just figured out this problem. Yes problem is not calling MesajDoldur() in every postback. Now I have an another problem. I want to change CssClass for clicked element. I can do it on RowInit event but page needs to be reload. How can I do it with JavaScript ? Here is my controls. I have two classes which are read and unread. On page load, in row init, I set them according to database column that keeps read/unread state. While page load completes, parent rows are stylized. I want to change class on row populating if the parent row is unread, set it to read.
<Columns> <ig:TemplateDataField Key="AdiSoyadi"> <Header Text="Gönderen </Header> <ItemTemplate > <asp:Label CssClass="selam" ID="lblRoom" runat="server" Text='<%# DataBinder.Eval(((Infragistics.Web.UI.TemplateContainer)Container).DataItem, "AdiSoyadi") %>'> </asp:Label> </ItemTemplate> </ig:TemplateDataField> <ig:TemplateDataField Key="Tarih"> <Header Text="Tarih"> </Header> <ItemTemplate > <asp:Label CssClass="selam" ID="lblRoom" runat="server" Text='<%# DataBinder.Eval(((Infragistics.Web.UI.TemplateContainer)Container).DataItem, "Tarih") %>'> </asp:Label> </ItemTemplate> </ig:TemplateDataField> </Columns> <Bands> <ig:Band Key="MessageContent" DataKeyFields="ID" DataMember="vMesaj" AutoGenerateColumns="False"> <Columns> <ig:TemplateDataField Key="Mesaj"> <header text="Mesaj" /> <itemtemplate> <asp:Label CssClass="selam" ID="lblRoom" runat="server" Text='<%# DataBinder.Eval(((Infragistics.Web.UI.TemplateContainer)Container).DataItem, "Mesaj") %>'> </asp:Label> </itemtemplate> </ig:TemplateDataField> </Columns> </ig:Band> </Bands>
Here is my Row_Init
protected void whgridShowMessages_InitializeRow(object sender, RowEventArgs e) { Messages = new clsMessages(); if (e.Row.Items.Count == 1) return;
int mesajRef = Convert.ToInt32(e.Row.DataKey[0]);
var ds = Messages.MesajGetir(RezervasyonRef, mesajRef, 1); int durum = Convert.ToInt32(ds.Tables[0].Rows[0][2]); if (durum == 0) { e.Row.Items[0].CssClass = "webDataExplorerMesajOkunmadi"; //(unread) e.Row.Items[1].CssClass = "webDataExplorerMesajOkunmadi"; } else { e.Row.Items[0].CssClass = "webDataExplorerMesajOkundu"; //(read) e.Row.Items[1].CssClass = "webDataExplorerMesajOkundu"; } }