I have two combo boxes, each one associated with a data source. The second combo box will depend on the first combo box. On the change for the first combo box, I get the new data(because of the new fetch criteria) for the second combo box, but how to repopulate the 2nd combo box? The example in the smartClient website for select dependency does not work for this case, because the data is hard coded in that example.
I came up a way to get the new data sent back from the client, but I don’t know how to repopulate the 2nd combo box using the data. The following is the sample code:
actually, When selection changes on the first select box, I need to just provide new filter
criteria for the second select box without changing the datasource.
The way to do this is to specify a getPickListFilterCriteria() on the second databound select box that automatically computes the appropriate criteria, then provide a change() handler on the first select box that calls clearValue() on the second combo box. So e.g, for your case:
So whenever the user changes Combo1, Combo2 will be reset and then when the user pulls down Combo2, it’ll automatically fetch data with the criteria returned by getPickListFilterCriteria(). Does this work for you?
Hi, I tried this piece of code in my program, because I also need a filtered combo box, but unfortunately it doesn’t work.
In my example both combo boxes use the same datasource. The first combo box shows postcodes and the second shows city-names. So when I pick a postcode the second combo box should only show the cities with the proper postcode.
But when I open the second combo box it shows all cities.
Interesting
If you’re overriding ‘getPickListFilterCriteria()’ we would expect this to work
Could you post the code for the Form containing the 2 comboBoxItems so we can take a look?
Hi Arne - I just tried your example and it basically worked for me.
However I noticed that you use “foo” as your fieldName in the generated criteria - is this a valid field-name from your dataSource?
If not I would expect this not to work if you’re using our built in SQL layer, as the server will be performing the filter based on the values for fields in the dataSouce only - other entries will essentially be ignored. Try changing to the fieldName of a field from your dataSouce (which sounds like what you’ll be doing for the “real” application) and see if that fixes the problem.
If not let us know and we’ll take a deeper look
Thanks
Isomorphic Software
populating combobox based on row details in a listgrid
Hi,
We have a similar requirement in a list grid. My code for the comboBox
getPickListFilterCriteria: function() {
// id = myForm.getValue(‘id’);
//here i need to access the record
}
I am not able to access the record object there(which will be used to set the criteria).
How to access the record items in the function…
Hey Arne, I am working on something very similar to your code. Can you tell me when you initially load a page with two combos and a first combo has a value selected is the second combo’s selection filtered on the value from the first one?
If you want to get the currently selected record on the ListGrid, you can use the getSelectedRecord() method. More generally, you can access the records in a ListGrid using the data property, then use List methods to get the specific record(s) you want.
How to get the listgrid object inside getPickListFilterCriteria
Hi
we are using datasource xml,
Inside the function we are not able to get listgrid object, in order to call getSelectedRecord()
How to get the listgrid object inside the function?
You can use the ID of the ListGrid to reference it from within the getPickListFilterCriteria method.
If your DataSource is going to be used in other applications, it’s probably better to put this method in your DynamicForm field definition instead of the DataSource itself so it would just be used for that DynamicForm.
You should be able to use a combination for listGrid.getEditedRow() and listGrid.getEditedRecord() (passing the result of the first call to the second to get the edited record). Does that work for you?