This is a migrated thread and some comments may be shown as answers.

Client bound dataform with client bound dropdownlists

1 Answer 55 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
CDK
Top achievements
Rank 1
CDK asked on 30 Dec 2019, 10:31 PM

I have a RadDataForm that contains several RadDropdownLists.   They are all using client binding each with their own instance of RadClientDataSource.

 

How can I unsure the dropdown list data is retrieved and bound before the dataform data is retrieved and attempted to bind?

 

eg.  I have event handler on OnSetValues as follows:

<telerik:RadDataForm RenderMode="Lightweight" runat="server" ID="RadDataForm1"
    DataKeyNames="RecordID" RenderWrapper="true"  ClientDataSourceID="RadClientDataSource1">
    <ClientSettings>
        <ClientEvents OnSetValues="dataFormSetValues" OnGetValues="dataFormGetValues" OnDataFormCreated="dataFormCreated"       />
    </ClientSettings>

 

function dataFormSetValues(sender, args) { 
 
        var dataItem = args;
 
       $telerik.findControl(document, "EditJobTypeDD").findItemByValue(dataItem.JobType).select();
 }

 

The .select() in the javascript function above will fail occasionally when the webservice for the form data returns quicker than the webservice to populate the dropdown list, because there are no items in the dropdownlist yet.

 

Is there a best practice to implement this sort of scenario correctly?

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 02 Jan 2020, 10:54 AM

Hello,

 

You can use the following approach to achieve this requirement:

1. Define a global var jobType=""; javascript variable

2. Inside the dataFormSetValues() function set the jobType to be dataItem.JobType

3. And then try the following:

<telerik:RadDropDownList ... OnClientLoad="dropDownListLoad">
JS:
            function dropDownListLoad(sender,args) {
                sender.findItemByValue(jobType).select();
            }

I hope this will prove helpful.

 

Regards,
Eyup
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
DataForm
Asked by
CDK
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or