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
2060
igCombo in igGrid not loading data
posted

I'm trying to use a combo in a grid as follows:

@(Html.Infragistics()
.Grid(Model)
.ID("grid1")
.PrimaryKey(nameof(LuItemType.ItemTypeId))
.UpdateUrl(Url.Action("UpdatingSaveChanges", "ItemType"))
.AutoGenerateLayouts(false)
.AutoCommit(true)
.Columns(column =>
{
column.For(x => x.ItemDesc).HeaderText("Description").DataType("string");
column.For(x => x.SafeWorkingLoad).HeaderText("SWL").DataType("string");
column.For(x => x.InspectionPeriodId).HeaderText("InspectionPeriod");
})
.Width("600px")
.Height("500px")
.Features(features =>
{
features.Updating()
.EditMode(GridEditMode.Row)
.EnableDeleteRow(true)
.EnableAddRow(true)
.ColumnSettings(settings =>
{
settings.ColumnSetting().ColumnKey(nameof(LuItemType.ItemDesc))
.EditorType(ColumnEditorType.Text).Required(true).Validation(true);
settings.ColumnSetting().ColumnKey(nameof(LuItemType.SafeWorkingLoad))
.EditorType(ColumnEditorType.Text).Required(true).Validation(true);
settings.ColumnSetting().ColumnKey(nameof(LuItemType.InspectionPeriodId))
.EditorType(ColumnEditorType.Combo)
.ComboEditorOptions(options =>
{
options.DataSourceUrl(Url.Action("GetComboData", "ItemType"))
.TextKey(nameof(LuInspectionPeriod.InspectionPeriodDesc))
.ValueKey(nameof(LuInspectionPeriod.InspectionPeriodId))
.Mode(ComboMode.DropDown);
})
.Required(true).Validation(true);
});

})
.DataSourceUrl(Url.Action("GetGridData", "ItemType"))
.DataBind()
.Render())

However, the combo isn't loaded with any data, so I'm seeing the Id of the row rather than the text description, and when I try to drop the list there's no data in it.

The data source method is as follows:


public class ItemType : LookUpController<LuItemType>
{

... SNIP ...

[ComboDataSourceAction]
public ActionResult GetComboData()
{
return View(RsContext.LuInspectionPeriod.AsQueryable());
}

}

 And the entity class looks like:

public partial class LuInspectionPeriod
{
public LuInspectionPeriod()
{
LiftingItem = new HashSet<LiftingItem>();
LuItemType = new HashSet<LuItemType>();
}

[Required]
public int InspectionPeriodId { get; set; }
[Required]
public string InspectionDesc { get; set; }
[Required]
public int? InspectionPeriodDays { get; set; }
[Required]
public int? InspectionPeriodMonths { get; set; }

public virtual ICollection<LiftingItem> LiftingItem { get; set; }
public virtual ICollection<LuItemType> LuItemType { get; set; }
}

When I click on a the cell with the combo I get this error in the console:


jquery.js:9566 GET https://localhost:44307/ItemType/GetComboData?textKey=InspectionPeriodId&valueKey=InspectionPeriodId&toLower=1&_=1492017867793 500 (Internal Server Error)

Is there anything obviously wrong with how I've set this up?

Parents
No Data
Reply
  • 2060
    Offline posted

    In light of the answer on another question I've just added a column for the primary key column as follows:

    @(Html.Infragistics()
    .Grid(Model)
    .ID("grid1")
    .PrimaryKey(nameof(LuItemType.ItemTypeId))
    .UpdateUrl(Url.Action("UpdatingSaveChanges", "ItemType"))
    .AutoGenerateLayouts(false)
    .AutoCommit(true)
    .Columns(column =>
    {
    column.For(x => x.ItemTypeId).HeaderText("ItemTypeId").DataType("string").Hidden(false);
    column.For(x => x.ItemDesc).HeaderText("Description").DataType("string");
    column.For(x => x.SafeWorkingLoad).HeaderText("SWL").DataType("string");
    column.For(x => x.InspectionPeriodId).HeaderText("InspectionPeriod");
    })
    .Width("600px")
    .Height("500px")
    .Features(features =>
    {
    features.Updating()
    .EditMode(GridEditMode.Row)
    .EnableDeleteRow(true)
    .EnableAddRow(true)
    .ColumnSettings(settings =>
    {
    settings.ColumnSetting().ColumnKey(nameof(LuItemType.ItemDesc))
    .EditorType(ColumnEditorType.Text).Required(true).Validation(true);
    settings.ColumnSetting().ColumnKey(nameof(LuItemType.SafeWorkingLoad))
    .EditorType(ColumnEditorType.Text).Required(true).Validation(true);
    settings.ColumnSetting().ColumnKey(nameof(LuItemType.InspectionPeriodId))
    .EditorType(ColumnEditorType.Combo)
    .ComboEditorOptions(options =>
    {
    options.DataSourceUrl(Url.Action("GetComboData", "ItemType"))
    .TextKey(nameof(LuInspectionPeriod.InspectionDesc))
    .ValueKey(nameof(LuInspectionPeriod.InspectionPeriodId))
    .Mode(ComboMode.DropDown);
    })
    .Required(true).Validation(true);
    });

    })
    .DataSourceUrl(Url.Action("GetGridData", "ItemType"))
    .DataBind()
    .Render())

    It's still not working, i.e. I can't edit the cells of any existing rows, and I can't drop the combo on the Add row, but I am getting a different error now:

    Uncaught Error: The specified record or property was not found. Verify the criteria for your search and adjust them if necessary.
    at $.(anonymous function).(anonymous function)._getLatestValues (https://cdn-xat $.(anonymous function).(anonymous function)._getLatestValues (https://localhost:44307/lib/jquery-ui/jquery-ui.js:144:25)
    at $.(anonymous function).(anonymous function)._startEditForRow (https://cdn-na.infragistics.com/igniteui/2016.2/xxx/xxx/js/infragistics.lob.js:493:29009)
    at $.(anonymous function).(anonymous function)._startEditForRow (https://localhost:44307/lib/jquery-ui/jquery-ui.js:144:25)
    at $.(anonymous function).(anonymous function)._startEditForElement (https://cdn-na.infragistics.com/igniteui/2016.2/xxx/xxx/js/infragistics.lob.js:493:26680)
    at $.(anonymous function).(anonymous function)._startEditForElement (https://localhost:44307/lib/jquery-ui/jquery-ui.js:144:25)
    at $.(anonymous function).(anonymous function)._clickTrigger (https://cdn-na.infragistics.com/igniteui/2016.2/xxx/xxx/js/infragistics.lob.js:493:13512)
    at $.(anonymous function).(anonymous function)._clickTrigger (https://localhost:44307/lib/jquery-ui/jquery-ui.js:144:25)
    at HTMLTableCellElement.proxy (https://localhost:44307/lib/jquery/dist/jquery.js:496:14)
    at HTMLDivElement.dispatch (https://localhost:44307/lib/jquery/dist/jquery.js:5206:27)

Children