Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
135
Ultrawebgrid into WebHierarchicalDataGrid
posted

Hi

I am Ultrawebgrid into WebHierarchicalDataGrid. Here is my code.

<ig:WebHierarchicalDataGrid ID="gvCostCenters" runat="server" InitialDataBindDepth="0"
Key="Parent" AutoGenerateColumns="false" AutoGenerateBands="false" DataKeyFields="CC_ID"
Height="600" Width="500" OnInitializeRow="gvCostCenters_InitializeRow1">
<Columns>
<ig:UnboundField Key="Notes" Width="30px" Footer-Text="...">
<Header Text="Notes" />
</ig:UnboundField>
<ig:BoundDataField DataFieldName="MI_YEAR" Key="MI_YEAR " Header-Text="Year" Hidden="true" />
<ig:BoundDataField DataFieldName="CC_NUM" Key="CC_NUM" Header-Text="Number" />
<ig:BoundDataField DataFieldName="CC_NAME" Key="CC_NAME" Header-Text="Name" Hidden="false" />
<ig:BoundDataField DataFieldName="CC_ID" Key="CC_ID" Header-Text="CC_ID" Hidden="True" />
<ig:BoundDataField DataFieldName="NO_MGT" Key="NO_MGT " Header-Text="Mgt" />
<ig:BoundDataField DataFieldName="NO_STAFF" Key="NO_STAFF" Header-Text="Staff" />
<ig:BoundDataField DataFieldName="TOTAL" Key="TOTAL" Header-Text="Total" />
<ig:BoundDataField DataFieldName="CHILDROWS" Key="CHILDROWS" Header-Text="" Hidden="true" />
<ig:BoundDataField DataFieldName="NUM_NOTES" Key="NUM_NOTES" Header-Text="" Hidden="true" />
<ig:BoundDataField DataFieldName="NUM_CHILD" Key="NUM_CHILD" Header-Text="" Hidden="true" />
<ig:BoundDataField DataFieldName="MI_ID" Key="MI_ID" Header-Text="" Hidden="true" />
</Columns>
<Bands>
<ig:Band Key="CC_ID" AutoGenerateColumns="false" DataKeyFields="CC_ID" DataMember="" >
<Columns>
<ig:BoundDataField DataFieldName="EMP_NUM" Key="EMP_NUM" Header-Text="Emp #" />
<ig:BoundDataField DataFieldName="EMP_NAME" Key="EMP_NAME" Header-Text="Employee Name" />
<ig:BoundDataField DataFieldName="CM_ID" Key="CM_ID" Hidden="true" />
<ig:BoundDataField DataFieldName="CC_ID" Key="CC_ID" Header-Text="Emp #" />
<ig:BoundDataField DataFieldName="EMP_TITLE" Key="EMP_TITLE" Header-Text="Title" />
<ig:BoundDataField DataFieldName="FTE" Key="FTE" Hidden="true" Header-Text="FTE" />
<ig:BoundDataField DataFieldName="EMP_MORS" Key="EMP_MORS" Header-Text="M/S" />
<ig:UnboundField Key="Notes" Width="30px" Footer-Text="...">
<Header Text="Adj" />
</ig:UnboundField>
<ig:BoundDataField DataFieldName="NUM_DISTRIBUTION" Key="NUM_DISTRIBUTION" Hidden="true" />
</Columns>
</ig:Band>
</Bands>
<Behaviors>
<ig:EditingCore>
<Behaviors>
<ig:CellEditing Enabled="true" EditModeActions-EnableF2="true">
<ColumnSettings>
</ColumnSettings>
</ig:CellEditing>
</Behaviors>
</ig:EditingCore>
</Behaviors>
</ig:WebHierarchicalDataGrid>

and the codebehind is like..

Boolean exportCC = false;
DataSet costAccounts;
EffortDistributionService svc;
List<string> msgs = new List<string>();

protected void Page_Load(object sender, EventArgs e)
{
try
{
currentPage = "EffortDistribution";
if (currentMI.modelInstanceID == Guid.Empty || currentMM.MM_P_OR_F_OR_T == "P")
{
Response.Redirect("Default.aspx");
return;
}

if (isInRole("Client"))
{
btnImport.Visible = false;
btnImportCM.Visible = false;
FileUpload1.Visible = false;
btnExportFTE.Visible = false;
if (!isInRole("ClientAdmin"))
{
btnQuery.Visible = false;
}

}
if (currentMM.MM_P_OR_F_OR_T == "F")
{
btnExportFTE.Visible = false;
btnAddFTE.Visible = false;
}

if (currentMM.readOnlyClient)
{
btnImport.Enabled = false;
btnImportCM.Enabled = false;
FileUpload1.Enabled = false;
btnAddFTE.Disabled = true;
}
svc = new EffortDistributionService();
if (!Page.IsPostBack)
{
int numYears = svc.getNumPreviousYears(this.currentMI.modelInstanceID);
ddlYears.Items.Clear();
if (numYears > 5)
{
numYears = 5;
}
for (int i = 1; i <= numYears + 1; i++)
{
ddlYears.Items.Add(i.ToString());
}

ddlYears.SelectedValue = "1";
}
hdnLastEdit.Value = currentMM.MM_LAST_EDIT.ToString();

costAccounts = svc.getCostCenters(this.currentMI.modelInstanceID, ddlYears.SelectedValue);
if (costAccounts.Tables[0].Rows.Count > 0)
{
DataRow[] childRows = costAccounts.Tables[0].Select("CHILDROWS > 0");
if (childRows.Length > 0)
{
string str_cc_id = childRows[0].ItemArray[3].ToString();
costAccounts.Tables[1].Merge(svc.getCostCenterChildren(new Guid(str_cc_id), currentMI.modelInstanceID).Tables[0]);
//DataSet costAccounts = svc.getCostCenters(rb, ddlYears.SelectedValue); // TODO - delete this line
DataColumn parentColumn = costAccounts.Tables[0].Columns["CC_ID"];
DataColumn childColumn = costAccounts.Tables[1].Columns["CC_ID"];
DataRelation relExpenseDistribution;
relExpenseDistribution = new DataRelation("CostCenterMembers", parentColumn, childColumn);
costAccounts.Relations.Add(relExpenseDistribution);
}
gvCostCenters.DataSource = costAccounts;
gvCostCenters.DataBind();


}
}
catch (Exception exp)
{
logutils.createExceptionLogEntry(exp, loggedInUserID);
Response.Write("<script>alert('An error occurred loading the Effort Distribution Screen.');</script>");
if (this.currentMI.modelType == null)
msgs.Add("Most likely this occurred because an active client related identifier was not passed.");
}
finally
{
if (svc != null)
{
svc.Dispose();
}
}
}

and in InitializeRow it is like

protected void gvCostCenters_InitializeRow1(object sender, Infragistics.Web.UI.GridControls.RowEventArgs e)
{
int level = Convert.ToInt32(((Infragistics.Web.UI.GridControls.ContainerGridRecord)(e.Row)).Level);
if (level == 0)
{
//If change has been made to the child records (based on count in column 6 > 0), add * to end of ST_NUM

if (Convert.ToInt32(e.Row.Items[8].Text) > 0)
{

if (Convert.ToInt32(e.Row.Items[10].Text) > 0 && e.Row.Items[2].ToString().IndexOf("*") == -1)
e.Row.Items[2].Text = e.Row.Items[2].Text + "*";

}

if (Convert.ToInt32(e.Row.Items[9].Text) > 0)
e.Row.Items[0].Text = "!";

//If row is expanded, load the child records and rebind the dataset
if (Convert.ToInt32(e.Row.Items[8].Text) > 0 )//&& e.Row.Expanded == true) //on sort, e.row.expanded might be referring to a different row...
{
String cc_id = e.Row.Items[4].Text;// ToString();
int count;
count = costAccounts.Tables[1].Select("CC_ID='" + cc_id + "'").Length;
if (count == 0)
{
DataSet childrows = svc.getCostCenterChildren(new Guid(cc_id), new Guid(e.Row.Items[11].Text.ToString()));
costAccounts.Tables[1].Merge(childrows.Tables[0]);

gvCostCenters.DataSource = costAccounts;
gvCostCenters.DataBind();


}
}
}
else
{
//If change has been made to the child records (based on count in column 6 > 0), add * to end of ST_NUM
if (Convert.ToInt32(e.Row.Items[8].Text)> 0 && e.Row.Items[1].ToString().IndexOf("*") == -1)
{
e.Row.Items[1].Text = e.Row.Items[1].Text + "*";

}
}

}

How can I make the child grid to populate as it is not populating currently.What am I missing? Please guide me.

I have also attached a screenshot.How to set datamember for childband?