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

ComboBox Control Focus question

2 Answers 73 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 06 Aug 2012, 06:55 PM
I am utilizing combo boxes in a form using declarative syntax.  Both are remote dataSource dependent and I have had some challenges in getting them to work properly, but I seem to finally have it down, except for one minor detail.

I want them to autobind and I have that enabled using the declarative syntax, but when I have them autobind and there is a valid value that they are looking up, the last one to finish grabs focus, and would rather a different control on the form get first focus.  I don't really want to embed view code into the dataSources, so my workaround at this point is to disable them initially and then renable them with a 2.5 second timer to ensure they have enough time to update.  This works, but it would be better if I could either tie it to an event related to the controls, or if I could prevent them from grabbing focus altogether.

Any thoughts would be appreciated.

Thanks.

2 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 10 Aug 2012, 03:43 PM
Hello Paul,

I am not sure if I understand correctly the exact scenario. Could you share your current implementation so I can check the setup?

Regards,
Daniel
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Paul
Top achievements
Rank 1
answered on 10 Aug 2012, 06:38 PM
I think I may have figured out a way of doing the binding without this effect, but basically I am using MVVM in conjunction with a model that is polling a shared datasource, but the shared datasource is filtering based on the ID associated with a bound field in the current model.  As a general example of what we are doing:

var model = new kendo.data.Model.define({
id: "CustId",
GetCityDatasource: function () {
return inScopeDatasources.CityDatasource;
},
fields: {
CustName: { type: "string" },
CustCityId: { type: "string" }
}

});

And the MVVM declaration something like:

<input data-role="combobox" data-filter="startswith" data-bind="value: CustCityId, source: GetCityDatasource" data-text-field="CityName" data-value-field="CityId" data-auto-bind="true" />

Now, the datasource has a parameter map function that reformats the standard filter parameters to our custom format and server filtering is true.  So when we bind the model to the DOM with the declarative combobox and there is an existing ID in the model, the control correctly reads the datasource and retrieves the model, but there is a slight delay when it does this.  After the delay, focus is on the combobox control with part of the value in the input box highlighted.

Now, I have created another model in which I create a new Datasource object on demand and embed it in the top level observable portion of the model.  This approach seems to work without the focus issues, so I am thinking that my problem is the fact that when the Datasource is defined externally to the model, the events notifications do not flow properly.

So I think I will alter my existing models with the focus problem to use dynamically generated models and see if this fixes each of my focus problem areas.

I'll let you know if I see any other issues.  The MVVM binding with declarative widget syntax is awesome, but I have run into a couple of other bugs and minor behavior limitations that I have had to work around.

Thanks.
Tags
ComboBox
Asked by
Paul
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Paul
Top achievements
Rank 1
Share this question
or