Infragistics 2013.2 コンボ (igCombo) とグリッド (igGrid) を含む単純な MVC4 ページがあります。
私のコントローラーは、Model に複数の DataTable ("table1"、"table2"、"table3" など) を持つ DataSet を返し、コンボには ViewBag からのテーブル名 ("table1" など) のリストが取り込まれます。
コンボで選択したテキスト (テーブル) に応じてグリッドを変更したいのですが、それは起こりません。コンボを変更しても、グリッドは最初のテーブルから変更されません。
Infragistics によると、これは可能であるはずです: 「DataSet へのバインド」セッションでigGrid を DataTableにバインドします。
私のコントローラー:
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);
}
私の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");
});
});
マイグリッド:
@(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())