RadGrid Client Side Binding in Control Designer

Posted by Community Admin on 05-Aug-2018 04:49

RadGrid Client Side Binding in Control Designer

All Replies

Posted by Community Admin on 18-Jan-2011 00:00

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);

Resulting in the "CategoryCode" parameter being empty during databinding, but have the correct value later on.

In fact, if I fill in the value in the textbox myself it works perfectly.  So I just need to change the order so databinding happens after "refreshUI".

For reference, this is how I'm telling the RadGrid which javascript method to use: 
<ClientSettings>
    <DataBinding SelectMethod="GetCategorizedProducts3" Location="/WebServices/CategoryLinks.asmx"
        SortParameterType="Linq" FilterParameterType="Linq">
    </DataBinding>
    <ClientEvents OnDataBinding="productsGrid_DataBinding" />
</ClientSettings>


Posted by Community Admin on 18-Jan-2011 00:00

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).

Regards,
Slavo
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.

This thread is closed