RadGrid Client Side Binding in Control Designer
I have added a RadGrid to a control designer attached to a User Control Widget, based on the standard examples for RadGrid client-side programatic databinding and Sitefinity 4 control designers. Everything is working as I expected except that the control designer's script is populating the control parameter values after the RadGrid's OnDataBinding client side event.
That's a problem since the RadGrid needs the controls parameters to pass them to the web service datasource.
For example:
The control designer's script to populate control properties
refreshUI:
function
()
var
data =
this
._propertyEditor.get_control();
var
param = data.CategoryCode;
if
(param ==
null
) param =
""
;
jQuery(
"#uiCategoryCode"
).val(param);
happens before the RadGrid databinding event that fills in the value in #uiCategoryCode
function
productsGrid_DataBinding(sender, args)
var
methodArguments = args.get_methodArguments();
args.set_location(
"/WebServices/CategoryLinks.asmx"
);
args.set_methodName(
"GetCategorizedProducts3"
);
var
myMethodArguments =
new
Object();
myMethodArguments.Category = jQuery(
"#uiCategoryCode"
).val();
args.set_methodArguments(myMethodArguments);
<
ClientSettings
>
<
DataBinding
SelectMethod
=
"GetCategorizedProducts3"
Location
=
"/WebServices/CategoryLinks.asmx"
SortParameterType
=
"Linq"
FilterParameterType
=
"Linq"
>
</
DataBinding
>
<
ClientEvents
OnDataBinding
=
"productsGrid_DataBinding"
/>
</
ClientSettings
>
Hello Jeff Dease,
The problem occurs, because you are binding the grid declaratively. When binding the grid this way, it calls the webservice on page load or later, but after the control designer's refreshUI method. What you can do is manually bind the grid in client-side code in the refreshUI method itself. That's what we are doing in the built-in control designers, too.
You can find more information about how to do this here: http://www.telerik.com/help/aspnet-ajax/grid-live-data-from-web-service.html (just do it once and not after a predefined interval with live data).