Hi,
I'm looking for a way to get a multiline combobox, because with valuekey and textkey I only have one column that is shown.
e.g. customer number, customer first name, customer family name which should be all shown when opening the combobox (comparable to the infragistics win forms combobox)
And which possibilies do I have, if i want to save the first customer name of the chosen datarow in a textfield.
txtTextfiedl.value = row("customer").customerfirstname
do you have an samples for this case, I could not find anything in the infragistcs samples.
Thank you.
Hello,
I am just following up to see if you need any further assistance with this matter.
Hi Tobias,
In default state, in order to reduce size of html, the Mvc Combo sends to client only data related to ValueKey and TextKey columns.
To pass all data to client, application should disable CompactData property.
On client application may get record related to an item (selected or any other) from original dataSource option. If dataSourceUrl is used or dataSource points to oData or similar, then application may get reference to actual data used by igCombo by processing dataBound event or using internal variable _dataSource.Note: the public getDataSource() method will be added to igCombo.
I wrote an example for you, which shows how to get record while processing selectionChanged event of igCombo. The dataSource on server generates data with 3 columns: I1, I2 and I3.
@Html.Infragistics().Combo("Combo1").DataSource(Model.GetData1()).CompactData(False).ItemTemplate("${I1}:<span unselectable='on' style='color:red'>${I2}</span>:${I3}").ValueKey("I1").TextKey("I2").Render()<script type="text/javascript"> $(function () { $('#Combo1').igCombo('option', 'selectionChanged', function (evt, ui) { var selItem = ui.items ? ui.items[0] : null; var val = selItem ? selItem.value : null; if (val === null) { alert('no sel'); return; } var item = ui.owner.itemByValue(val); var index = item.index; var ds = ui.owner.options.dataSource; var record = null; //if (ds && typeof ds !== 'string') { //record = ds[index]; //} //ds = ui.owner._dataSource; ds = ui.owner.referenceToDataSource; if (ds) { record = ds.data()[index]; } alert('sel item:'+item.index+':'+item.value+':'+item.text+'='+record.I1+':'+record.I2+':'+record.I3); }); $('#Combo1').igCombo('option', 'dataBound', function (evt, ui) { ui.owner.referenceToDataSource = ui.dataSource; }); });</script>
i also use datasourceURL instead of a direct datasource as in the sample
thanks.
but I have got problems using this answer.
I use Asp.Net MVC3 with razor syntax vbhtml.
When comparing this combo functionality to the Infragistcs combo win forms, then there are no headings in the itemtemplate combobox.
moreover I can only use 2 fields which are in valuekey or textkey.
and in the selectionchanged function: the items[0].value or items[0].text only contains the values for key and text,
but not those fields I want to use in the itemtemplate.
example: key = employeenumber and text = employeename
but in the itemtemplate I want to use: telephone number / frist / second / family name / department.
and after selecting one row, in my application the text boxes telephone, department, first , second name will be filled with the information,
but items(0).value or text only contains emplyoeenumber and employeename, but not telephone etc ...
in infragistics win forms combo the designer was excellent and easy to handle.
maybe could could send me a sample in ASP.Net MVC, how to deal with such general combobox issues.
thanks in advance.
You can use a template to do that. Just define itemTemplate property of the igCombo. Use ${FieldName} syntax to put your data fields in the template string (Example: itemTemplate: "${FirstName} ${SecondName} ${LastName}"). However there is a little problem. When you select item from the combo the string in the combo will not be the string from the item, but only the value of the column declared in the nameKey property.
You can use the igCombo.value method to get the selected value.
Alternatively you can bind to selectionChanged and use the ui.items[0].value .
I've attached a sample which demonstrates the described solution.
Hope this helps,
Martin Pavlov
Infragistics, Inc.