Not sure if this is a bug, or I'm doing something wrong.
I have a custom Tab in the TaskEditor in Gantt - with a combo field, whose items is populated by a store. I've got everything working ok, except the data in the property on my task does not show in the combo. I have other combos on the same tab populated with static items that work fine.
The store is defined by the following; The initial load here is some custom functionality we need to have an initial list of certain users to pick from, then the remote filtering will kick in when a search field is provided.
I added a change listener to the combo, so I know the data is there, as the value on the change listener is populated on load. I assumed it was because the usernames in ownerUsernames was not loaded in the store initially, so I added them to the initial load. However it is still not showing up.
Should the AjaxStore do a request to load data about the current value on load? What am I missing?
I'll try and find some time to create a repro, just going to be a biggish job, as it's going to need a backend of some description.
In the mean time, I tried autoLoad, that just seems to call the readUrl with no filter or params, which for our use case isn't suitable due to the number of records that will be returned.
I'm hoping if I provide enough information we can figure out how it's supposed to work, and how I can modify what I'm doing.
The task has an array of usernames in the ownerUsernames property, I have this bound to a combo on a custom tab. That combo is backed by an ajax store. The combo uses the chipView.itemTpl to show the fullName property of the user. The ownerUsernames field has a value as shown below;
I've been trying some things in onBeforeTaskEditShow. I've tried setting the items of the combo, tried setting the data of the AjaxStore, tried autoLoad, tried manually setting the value of the combo.
Even manually setting the combo value doesn't seem to work properly, as setting it to the array of values, seems to internally set it to the first item in the array, but the accessor for value shows an empty array.
The combo also seems to never get set to the value specified by the value of the field set to "name" - in this case - ownerUsernames.
I've found some inconsistency in work with AjaxStore in our combo that I am currently discussing with the team and will notify you about later. As a workaround, you could try to set value to the combo after the combo has been loaded:
#1 - you should use or items or store, not together. So please remove items.
#2 - if you load data remotely, you should't set it manually. This line is also unuseful.
Regarding to the initial issue you mentioned, here is a ticket: https://github.com/bryntum/support/issues/2738
There is a bug and it should work without a workaround. You can subscribe on the updates to be notified when it fixed.
Thank you for your report and time,
Best regards,
Alex
I'm still running into weird issues. On load of the store I am setting the value of the combo, however still no records show. Setting a breakpoint in the load handler, I can see I am setting the value to an array of two usernames, right after setting the value on the combo, getting the value of the combo returns an empty array.
In addition the initial load of the data seems ok in that logging out the ._data of the store shows the two complete records, but then in the next breakpoint, data seems to be an array with a single value equal to the array of the two usernames. It almost seems as if the binding to the task record is overwriting the store data, and adding an array of values as the first array value, rather than spreading the array, and in addition losing the extra data that the store provides.
I think there's definitely some issues using a multiselect combo with an ajax store, that hopefully the above issue will address. I think at the moment I am unable to use it for our intended purpose. Is there any chance of getting the fix added to a patch release? Or is there an ETA on 4.2.x being released?
I am not sure about that data replacing problem. That sounds weird, I cannot reproduce that.
Did you add your fields to store model?
The solution I suggested before works to me, I tested it with some public API, please take a look:
const countryStore = new AjaxStore({
fields : ['alpha3Code', 'name'],
readUrl : 'https://restcountries.eu/rest/v2/all' // or copy JSON to your local server.
});
const gantt = new Gantt({
appendTo : 'container',
features : {
taskEdit : {
items : {
generalTab : {
// change title of General tab
title : 'Common',
items : {
customCombo : {
type : 'combo',
name : 'countries',
label: 'Countries',
multiSelect: true,
valueField: 'alpha3Code',
displayField: 'name',
store: countryStore
}
}
},
[....]
listeners : {
beforeTaskEditShow({ taskRecord, editor }) {
const { customCombo } = editor.widgetMap;
// for test, set multi value after the data loaded using ids
customCombo.store.on('load', () => {
customCombo.value = ['AFG', 'ALA'];
});
customCombo.store.load();
}
},
Please try it and if possible, describe clear steps to reproduce for the issue you mentioned in your last post.
I'm really sorry, but I still can't get it to work. No matter what I try, I cannot get the value to display in the multiselect combo backed by an ajax store. I have other combos backed by items which work fine.
Here is the full code of my custom task editor tab
Thank you for the provided information! I see the problem! Unfortunately there is one more bug.
The difference via our solutions is in use filterParamName config. If it has been set, the bug appears. Here is a ticket: https://github.com/bryntum/support/issues/2775
I will try to push it with a high prio.