1

I have a simple MVC4 page with a Infragistics 2013.2 Combo (igCombo) and a Grid (igGrid).

My controller return a DataSet with multiples DataTable ("table1", "table2", "table3", etc.) in Model and the combo is populated with a lista of tables names ("table1", etc) from ViewBag.

I want to change the grid according to the selected text (table) in the combo but its not happening. When a change the combo the grid doesn't change from the initial table.

Acording to Infragistics this should be possible: Binding igGrid to DataTable at "Binding to DataSet" session.

My controller:

public PartialViewResult Test1()
{
    DataSet dts = new DataSet();

    //table1
    DataSet tempDts = "select COL1, COL2, COL3 from table1";
    tempDts.Tables[0].TableName = "table1";
    dts.Tables.Add(tempDts.Tables[0].Copy());

    //table2
    DataSet tempDts = "select COL4, COL5, COL6, COL7, COL8 from table2";
    tempDts.Tables[0].TableName = "table2";
    dts.Tables.Add(tempDts.Tables[0].Copy());

    //table3
    DataSet tempDts = "select COL9, COL10 from table3";
    tempDts.Tables[0].TableName = "table3";
    dts.Tables.Add(tempDts.Tables[0].Copy());

    String[] listTables = new String[] { "table1", "table2", "table3" };

    ViewBag.Combo = listTables;

    return PartialView(dts);
}

My Javascript:

$(function () {
    $(document).delegate("#combo1", "igcomboselectionchanged", function (evt, ui) {
        //At debug I confirmed that ui.items[0].value is "table2"
        $("#grid1").igGrid("option", "dataMember", ui.items[0].value);
        $("#grid1").igGrid("dataBind");
    });
});

My Grid:

@(Html.Infragistics()
.Grid<DataTable>()
.ID("grid1")
.AutoGenerateColumns(true)
.Features(features =>
{
    features.Resizing();
    features.RowSelectors().RowSelectorsColumnWidth("25px").EnableRowNumbering(false);
    features.Selection().Mode(SelectionMode.Row).MultipleSelection(false);
    features.Paging().PageSize(10);
})
.Height("100%")
.DefaultColumnWidth("150")
.DataMember("table1")
.DataSource(Model)
.DataBind()
.Render())

0 Answers0