This question is locked. New answers and comments are not allowed.
*Not sure if I should put this in the Grid Forum or here*
I added a Combobox to a Grid ToolBar which I use to filter the data. If I try to select the first item in the Combobox onLoad it does select the first item and loads the gird data correctly. However the next 'mouse click' anywhere on the page (white-space, button, link, etc) fires the onChange event again, which rebinds the grid. If I don't call the onChange event inside the onLoad event for the Combobox, I have to 'click' to fire the event and load the Grid data. Not sure why the event is getting fired again or not fired?
Here is the Grid's Toolbar:
I added a Combobox to a Grid ToolBar which I use to filter the data. If I try to select the first item in the Combobox onLoad it does select the first item and loads the gird data correctly. However the next 'mouse click' anywhere on the page (white-space, button, link, etc) fires the onChange event again, which rebinds the grid. If I don't call the onChange event inside the onLoad event for the Combobox, I have to 'click' to fire the event and load the Grid data. Not sure why the event is getting fired again or not fired?
Here is the Grid's Toolbar:
.ToolBar(toolBar => toolBar.Template( @<text> <label> Select a Type: </label> @(Html.Telerik().ComboBox() .Name("MyTypes") .DataBinding(binding => binding.Ajax().Select("_GetTypes", "MyController")) .AutoFill(true) .Filterable(filtering => { filtering.FilterMode(AutoCompleteFilterMode.StartsWith); }) .HtmlAttributes(new { style = "width: 350px" }) .HighlightFirstMatch(true) .ClientEvents(events => events .OnLoad("My.Namespace.Type_OnLoad")
.OnChange("My.Namespace.Type_OnChange") ) ) </text> )) Here is the javascript:My.Namespace = { param1: "", param2: "", Type_OnLoad: function (e) { var combobox = $("#MyTypes").data("tComboBox");}
combobox.fill(function () { //binds the combobox combobox.select(0); //select the first item. My.Namespace.Type_OnChange(e); //rebind }) }, Grid_onDataBinding: function (e) { var params = $("#MyTypes").data("tComboBox").value().split(','); My.Namespace.param1 = params[0]; My.Namespace.param2 = params[1]; //Only bind data when a Type is selected if (My.Namespace.param1 == "" || My.Namespace.param2 == "") { return false; } e.data = $.extend(e.data, { Param1: My.Namespace.param1, Param2: My.Namespace.param2 }); }, Type_OnChange: function (e) { $("#Grid").data("tGrid").rebind(); },