Hi guys, good day to you.
I've implemented an RadComboBox with multiple columns in an item template and using automatic load on demand on a very large dataset, and it is working very well.
However i have some questions I hope you can help me.
1) The combobox is implemented using Filer="Contains", and it searches across all the columns in the item template using ItemsPerRequest = "10". In order to achieve this, I've created a column in the datasource called "SearchColumn", which is a string consisting of "col1" + "col2"+"col3" etc.... The DataTextField is then set to DataTextField = "SearchColumn". This works very well and implements the search functionality that I want. But because the DataTextField is now this SearchColumn, whenever the user clicks an item, the text in the RadComboBox becomes this very long string. For example, if I have a row in the dropdown with columns - "Vehicle0001" "Car" "Blue" "4 wheels",my SearchColumn becomes "Vehicle0001CarBlue4Wheels", and if the user searches any of these columns the row will show up. Clicking on the item will set the text in the RadComboBox to "Vehicle0001CarBlue4Wheels". But this is not what I want to display as the text, so I have added a viewstate variable to store and display the selected value,
RadComboBox_SelectedIndexChanged(Object sender, EventArgs e)
{
ViewState["SelectedVehicle"] = e.SelectedValue
}
and added a line in Page_PreRender to always set the text to the value to display.
protected void Page_PreRender(object sender, EventArgs e)
{
RadComboBox.Text = ViewState["SelectedVehicle"]
}
Is this the recommended way to implement a search across all columns and yet display a different text on selection? I am wondering if there is a property to set in the RadComboBox control to indicate which is the datafield to search ("SearchColumn"), or does it only search the DataTextField?
2) This method is working very well for me, but there is a small problem. If the user click the RadComboBox and expands the drop down, but does not change anything, it will auto set the value to the DataTextField ("Vehicle0001CarBlue4Wheels") and not "Vehicle0001" since there is no postback. What is the recommended way to resolve this?
3) I am hoping to replace the Page_Prerender server side setting the ViewState variable, with a client side set text setting after every SelectedIndexChanged. So I have tried something like this, changing the SearchColumn to be something like Col1+ '|' + Col2 .... so "Vehicle0001CarBlue4Wheels" becomes "Vehicle0001|Car|Blue|4Wheels", then I added OnClientSelectedIndexChanged function following the demo
function RadComboBoxOnClientSelectedIndexChanged(sender, eventArgs) {
var item = eventArgs.get_item();
sender.set_text(item.get_text().split("|")[0]);
}
But there is a problem, the RadComboBoxOnClientSelectedIndexChanged is called before server processes the server side function RadComboBox_SelectedIndexChanged. By calling sender.set_text(); on a custom value, the SelectedValue becomes "", it will never select the correct item. How should I resolve this? Is there a way to call set_text after server processes RadComboBox_SelectedIndexChanged?
Thanks for reading.
I've implemented an RadComboBox with multiple columns in an item template and using automatic load on demand on a very large dataset, and it is working very well.
However i have some questions I hope you can help me.
1) The combobox is implemented using Filer="Contains", and it searches across all the columns in the item template using ItemsPerRequest = "10". In order to achieve this, I've created a column in the datasource called "SearchColumn", which is a string consisting of "col1" + "col2"+"col3" etc.... The DataTextField is then set to DataTextField = "SearchColumn". This works very well and implements the search functionality that I want. But because the DataTextField is now this SearchColumn, whenever the user clicks an item, the text in the RadComboBox becomes this very long string. For example, if I have a row in the dropdown with columns - "Vehicle0001" "Car" "Blue" "4 wheels",my SearchColumn becomes "Vehicle0001CarBlue4Wheels", and if the user searches any of these columns the row will show up. Clicking on the item will set the text in the RadComboBox to "Vehicle0001CarBlue4Wheels". But this is not what I want to display as the text, so I have added a viewstate variable to store and display the selected value,
RadComboBox_SelectedIndexChanged(Object sender, EventArgs e)
{
ViewState["SelectedVehicle"] = e.SelectedValue
}
and added a line in Page_PreRender to always set the text to the value to display.
protected void Page_PreRender(object sender, EventArgs e)
{
RadComboBox.Text = ViewState["SelectedVehicle"]
}
Is this the recommended way to implement a search across all columns and yet display a different text on selection? I am wondering if there is a property to set in the RadComboBox control to indicate which is the datafield to search ("SearchColumn"), or does it only search the DataTextField?
2) This method is working very well for me, but there is a small problem. If the user click the RadComboBox and expands the drop down, but does not change anything, it will auto set the value to the DataTextField ("Vehicle0001CarBlue4Wheels") and not "Vehicle0001" since there is no postback. What is the recommended way to resolve this?
3) I am hoping to replace the Page_Prerender server side setting the ViewState variable, with a client side set text setting after every SelectedIndexChanged. So I have tried something like this, changing the SearchColumn to be something like Col1+ '|' + Col2 .... so "Vehicle0001CarBlue4Wheels" becomes "Vehicle0001|Car|Blue|4Wheels", then I added OnClientSelectedIndexChanged function following the demo
function RadComboBoxOnClientSelectedIndexChanged(sender, eventArgs) {
var item = eventArgs.get_item();
sender.set_text(item.get_text().split("|")[0]);
}
But there is a problem, the RadComboBoxOnClientSelectedIndexChanged is called before server processes the server side function RadComboBox_SelectedIndexChanged. By calling sender.set_text(); on a custom value, the SelectedValue becomes "", it will never select the correct item. How should I resolve this? Is there a way to call set_text after server processes RadComboBox_SelectedIndexChanged?
Thanks for reading.