Skip to content

Replies

0
Lile
Lile answered on Jan 29, 2016 1:02 PM

I think the "data-id" row attribute is generated automatically when a primary key is assigned to the row, and correlates to the value of the PK.

In my example, I was dealing with a hierarchical grid bound to a dataset of related tables (PK/FK relation).

0
Lile
Lile answered on Nov 3, 2014 6:24 PM

I marked my last post as the answer, but if anyone has a better way to do this I'd love to know.

Thanks.

0
Lile
Lile answered on Nov 3, 2014 6:07 PM

Update:

Due to the way that the allChildrenWidgets() method works, it was necessary to add a bit of code to retrieve the correct item from the array.

 

$("#gridContracts").on("ighierarchicalgridrowexpanding", function (evt, ui)

{    

    var parentRow = ui.parentrow;    

    var parentRowId = parentRow.attr("data-id");    

    var simId = $("#gridContracts").igGrid("getCellValue", parentRowId, "Simulation_id");    

    // get primary key value from parent row

    var pk = $("#gridContracts").igGrid("getCellValue", parentRowId, "Contract_id");    

    var childGrids = ui.owner.allChildrenWidgets();

    // loop thru array of allChildrenWidgets()

    for (var i = 0; i < childGrids.length; i++)    

    {        

        // compare pk to fk of first row in each grid item

        if (childGrids[i].getCellValue(childGrids[i].rows(0).attr("data-id"), "Contract_id") == pk)        

        {            

             childGrids[i].setColumnTemplate(childGrids[i].options.columns[0].key, "<a href=\"targetpage.aspx?s_id=" + sim_Id + "&v_id=${Version_id}\" target=\"_self\">Details</a>", true);        

             break;

        }    

    }

});

0
Lile
Lile answered on Nov 3, 2014 3:37 PM

Tsanna,

Using the RowExpanding event of the igHierarchicalGrid, I was able to get the desired result. (See below)

If there is a better or more efficient way to achieve this, please let me know.

 

$("#gridContracts").on("ighierarchicalgridrowexpanding", function (evt, ui)

{

var parentRow = ui.parentrow;

var parentRowId = parentRow.attr("data-id");

// get the value from the parent row cell by column key

var simId = $("#gridContracts").igGrid("getCellValue", parentRowId, "Simulation_id");

// get a the child grid object

var childGrid = ui.owner.allChildrenWidgets()[0];

// set the column template

childGrid.setColumnTemplate(childGrid.options.columns[0].key, "<a href=\"targetpage.aspx?s_id=" + simId + "&v_id=${Version_id}\" target=\"_self\">Details</a>", true);

});

0
Lile
Lile answered on Nov 3, 2014 1:45 PM

Thanks Tsanna,

Specifically, I want to create a hyperlink column in a child row, which uses a parent row cell value in the querystring of the target path.

In the code below, I am setting the Template property of the 'Details' column in ColumnLayouts, but I am unable to capture 'Simulation_id' from the parent level.

 

@(Html.Infragistics().Grid<Contract>()

    .ID("gridContracts")

    .Width("100%")

    .Height("600px")

    .AutoGenerateColumns(true)

    .AutoGenerateLayouts(true)

    .PrimaryKey("Contract_id")

    .Columns(cols =>

    {

        cols.For(x => x.Simulation_id).HeaderText("").Width("100px");

        cols.For(x => x.Contract_id).HeaderText("").Width("100px");

        cols.For(x => x.ContractName).HeaderText("Contract");

    })

   

    …

 

    .ColumnLayouts(layouts =>

    {

        layouts.For(x => x.Versions)

        .PrimaryKey("Version_id")

        .ForeignKey("Contract_id")

        .Columns(cols =>

        {

            cols.For(x => x.Details).HeaderText("Details").HeaderText("").Width("100px")

                .Template("<a href=\"Provision.aspx?s_id=${parent.Simulation_id}&v_id=${Version_id}\" target=\"_self\">Details</a>");

           

           …

 

        })

       

        …

 

    })

    .DataSource(Model)

    .DataBind()

    .Render()

)