Hi,
I have another question on having igCombo as editor inside an igGrid. I set up my editor something like this:
features.Updating() .EnableAddRow(true) .EnableDeleteRow(true) .EditMode(GridEditMode.Row)
.ColumnSettings(s =>
{
s.ColumnSetting().ColumnKey("Product").EditorType(ColumnEditorType.Combo) .ComboEditorOptions(options => { options.DataSource(Model.Products).TextKey("ProductName").ValueKey("ProductID"); });
}
When I select a product from the combo, the ProductName is displayed, but when I clicked the 'Done' button, the ProductID is displayed instead of the ProductName.
Is this the intended behavior ? if so, is there any way around it ? I want to display the text value after the edit mode ended.
Also, why is the combo data source not getting the whole object that I passed in from the MVC controller ? let's say my Product entity has ID, Name, Price, and Description. Only the Name and ID are available inside the data source since it's set as Text and Key value.
Thanks,
Jeffrey
Hi Jeffrey,
The behavior is correct, because at the end the igCombo.options.valueKey is what it gets to the underlying data source and that value is displayed in the cell. You can workaround it as I described in this forum thread:
http://ko.infragistics.com/community/forums/p/72892/370474.aspx#370474
jAndika said: Also, why is the combo data source not getting the whole object that I passed in from the MVC controller ? let's say my Product entity has ID, Name, Price, and Description. Only the Name and ID are available inside the data source since it's set as Text and Key value.
I don't know the exact reason, but I guess this is done to save network traffic. textKey and valueKey properties are all that igCombo is needing to do its job and thus the data source is stripped to these two properties.
Best regards,
Martin Pavlov
Infragistics, Inc.
Martin & Viktor,
Thanks for the reply. I run into another problem trying to implement that mapping solution. I'm using MVC helper to build the grid, and below is how I set it:
.Columns(column =>{ column.For(c => c.ProductName).DataType("string").HeaderText("Product").FormatterFunction("lookupProductName");}).Features(features =>{ features.Updating() .EnableAddRow(true) .EnableDeleteRow(true) .EditMode(GridEditMode.Row) .ColumnSettings(s => { s.ColumnSetting().ColumnKey("Product").EditorType(ColumnEditorType.Combo) .ComboEditorOptions(options => { options.DataSource(Model.Products).TextKey("ProductName").ValueKey("ProductID"); }); });})
Here's my lookupProductName function:
function lookupMfrCode(productID) { if(productID) return comboMapProduct[productID];}
The problem is when rendering the grid first time or any regular grid row, the value that gets passed into lookupMfrCode is ProductName instead of ID, and since the mapping key is based on ProductID, the function does not return anything and throws an error.
Am I missing something here ? Is there another property I need to set inside the column or columnSetting ?