How can fill combos and use mapper property to select the item come to the Model? In grids MVC. Its something like this?
new GridUpdating() { ColumnSettings = new List<ColumnUpdatingSetting>() { new ColumnUpdatingSetting() { ColumnKey= "CodTipoDireccion", EditorType= ColumnEditorType.Combo, EditorOptions = "",ComboEditorOptions = new ColumnUpdatingComboEditorOptions() }{ DataSourceUrl = Url.Action("ObtenerCatalogoTipoDireccionesl")} } } }
Hello pedro,
Thank you for posting in our community.
Currently we do not have the mapper option added to the MVC wrapper for igGrid. The reason is that only a function could be set for this option. What I can suggest as a workaround in your scenario is handling dataBinding event and setting the mapper to the column of your choice trough the data source schema. For example:
//Delegate $(document).delegate("#grid1", "iggriddatabinding", function (evt, ui) { var a = 5; ui.dataSource.settings.schema.fields[3].mapper = function (record) { return record.ProductStatus.Name; } ui.dataSource._fields["ProductStatus"] = ui.dataSource.settings.schema.fields[3]; ui.dataSource._hasMapper = true; });
Please keep in mind that the dataType of the column that will use mapper should be set to object.
I created a small sample illustrating my suggestion and I am attaching it for your reference. Please have a look at this sample and let me know if you have any additional questions.
I hope you will find this information helpful.
Thank you for using Infragistics components.
I confuse with the function (record) { return record.ProductStatus.Name; }
because I load the combo like this
This is my grid column in MVC
columnas.For(item => item.CodTipoDireccion) .HeaderText("Codigo") .Width("180px").DataType("object");
I fill the combo in this column this
grid.Updating().EnableAddRow(false).ShowDoneCancelButtons(false).ColumnSettings(settings =>{ settings.ColumnSetting().ColumnKey("Codigo").EditorType(ColumnEditorType.Combo) .ComboEditorOptions(s => s.DataSource(CatalogosDireccion).TextKey("DesElemento").ValueKey("CodElemento").Mode(ComboMode.DropDown)); });
Cant use mapper to map the value come to the model and id information load in the combo.
Thank you for getting back to me.
By design mapper option that we introduced in version 16.1 is targeting igGrid and its ability to handle complex objects in its underlying data source. The mapper function can be used in scenarios where you have a complex data object and you need to extract specific property from it, which will define both the display value and the value used for data operations on that column. For such scenarios the column dataType needs to be specified as "object" and a mapper function can be used to extract the desired data from the record. The mapping is done on a data source level and will allow all data operations to be executed based on the mapped values. Basically this new option targets igGrid rather than igCombo.
If you would like to configure igCombo display text and value my suggestion is using textKey and valueKey options of the control.
Some further information regarding mapper function could be found at the following link:
http://www.igniteui.com/help/iggrid-columns-and-layout#defining-mapper
I hope you find this information helpful.
Please let me know if you need any further assistance with this matter.