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
45
Hierrarchical Grid - Not able to add child row for a parent row in client-side
posted

Hi,

My requirement is as follows.

I have an igGrid which is bound to model data(IQueryable) from controller/action. This displays list of parent rows.

Now i need to add child row for a selected parent row in the client side.

My client code for the same is as follows.

var attributeDetail = {

SalesQuotationItemID: $("#SalesQuotationItemID").val(),
SalesQuotationItemAttributeID : 1,
ItemAttributeTemplateDetailModelList: attList,
UnitPrice: $("#UnitPrice").val(),
InquiredQty: $("#InquiredQty").val(),
Discount: $("#Discount").val(),
TaxPercent: $("#TaxPercent").val(),
TotalAmount: $("#TotalAmount").val()
};

var childGridId = "#grdItems_" + PARENTID + "_" + "LAYOUTID" + "_child";

$(childGridId).igGridUpdating("addRow", attributeDetail);
$("#grdItems").igHierarchicalGrid("dataBind");

When i execute the above code, no error is thrown and child row also not displayed.

Infragistics grid MVC helper is as follows.

@(Html.Infragistics()

.Grid(Model.SalesQuotationViewModel.SalesQuotationItemViewModelList)
.ID("grdItems")
.Height("250px")
.PrimaryKey("SalesQuotationItemID")
.AutoGenerateColumns(true)
.AutoGenerateLayouts(true)
.RenderCheckboxes(true)
.Columns(column =>
{
column.For(x => x.SalesQuotationItemID).Hidden(true);
column.For(x => x.SalesQuotationID).Hidden(true);
column.For(x => x.StockID).Hidden(true);
column.For(x => x.ItemName).HeaderText("Item").Width("90%");
column.For(x => x.AddButton).HeaderText("").Width("10%").Template("");
})
.ColumnLayouts(layouts =>
{
layouts.For(x => x.SalesQuotationItemAttributeViewModelList)

.Features(childFeature =>
{
childFeature.Updating().EnableAddRow(false);
childFeature.Selection();
})
.PrimaryKey("SalesQuotationItemAttributeID")
.ForeignKey("SalesQuotationItemID")
.AutoGenerateColumns(false)
.AutoGenerateLayouts(true)
.Columns(column =>
{
column.For(x => x.SalesQuotationItemID).Hidden(true);
column.For(x => x.SalesQuotationItemAttributeID).Hidden(true);
column.For(x => x.ItemAttributeDisplayName).HeaderText("Item Detail");
column.For(x => x.Uom).HeaderText("UOM");
column.For(x => x.InquiredQty).HeaderText("Inquired Quantity").Template("

${InquiredQty}

").Format("0.000"); ;
column.For(x => x.UnitPrice).HeaderText("Unit Price").Template("

${UnitPrice}

").Format("0.00");
column.For(x => x.Discount).HeaderText("Discount").Format("0.00").Template("

${Discount}

");
column.For(x => x.TaxPercent).HeaderText("Tax Percent").Template("

${TaxPercent}

").Format("0.00"); ;
column.For(x => x.TotalAmount).HeaderText("Total Amount").Template("

${TotalAmount}

").Format("0.00");
column.For(x => x.AddButton).Template("");
});

})
.Features(feature =>
{
feature.Updating().EnableAddRow(false);
feature.Sorting();
feature.Selection();
feature.Paging().PageSize(10).ShowPageSizeDropDown(false);
})
.DataSource(Model.SalesQuotationViewModel.SalesQuotationItemViewModelList)
.AutoCommit(true)
.DataBind()
.Render()

)

Do I need to change something in my jquery script or in Grid property?

Thanks in advance.

Regards

Babu

Parents
  • 10685
    Suggested Answer
    Offline posted

    Hello Kassoft,

    I could see from the code pasted it is, and yet I suggest you to make sure to enable the updating feature for the particular child layout childFeature.Updating(), so the new row is added and rendered. Also I suggest make sure you are passing the correct childGridId as the string is error prone. For example I could not see the variables initialization and there could be an issue too. (var childGridId = "#grdItems_" + PARENTID + "_" + "LAYOUTID" + "_child"; )

     

    I have created a simple HTML sample illustrating a similar approach, as it is always easier to work with runnable samples. You could compare it with your approach and see how it works. If the issue persists, could you please attach a sample so I could further look into the matter and debug it.

     

    Relevant Info:

    RowAdding programmatically: http://help.staging.infragistics.local/Doc/jQuery/2014.1/?page=igGrid_Updating.html

    igHierarchicalGrid_AddChildRow.zip
Reply Children
No Data