Hello,
I have a picklist/Kendo Combobox that I am trying to filter based on its picklist code.
My picklist looks like this(I haven't included all the attributes of the select list like we have):
<select id="users"> <option value="1" code="user1" data-message="OK1">User 1</option> <option value="2" code="user2" data-message="OK2">User 2</option> <option value="3" code="user3" data-message="OK3">User 3</option> <option value="4" code="user4" data-message="OK4">User 4</option> </select>
I am performing a filter using the kendo dataSource Filter function:
$(document).ready(function() { var _flt = { logic: "or", filters: [] }; // Show only User 3 and User 4 var users = $("#users").data("kendoComboBox"); _flt.filters.push({ field: 'value', operator: "contains", value: "2" }); _flt.filters.push({ field: 'value', operator: "contains", value: "3" });
$('#users').data('kendoComboBox').dataSource.filter(_flt); });
However after the filtering is performed, the options lose their attributes i.e. code and data-message and only id remains. Any suggestions why? Kindly let me know.
Cheers.
To re-initialize the widget with code attributes, you can add the followiwng code snippet after filter call:
var fieldContext = rbf_getFieldContext('users');// where 'users' is field integration name...
fieldContext.setOptionCodes(fieldContext.getContainer() , fieldContext.getFieldData());
This doesn't seem to work Siraj. It says:
'fieldContext.setOptionCodes is not a function' in the Console window. Any suggestions on how I can fix this please?
My apologies, shared the wrong snippet earlier.
Please try:
var fieldContext = rbf_getFieldContext('users');// where 'users' is field integration name...
rb.newui.fields.SelectList().setOptionCodes(fieldContext.getContainer() , fieldContext.getFieldData());
Note: setOptionCodes is available starting 4.0.2.
Thanks that works now.
Iram
There is a small issue with this now [mention:78c86023544844079dc6455a4a7a4d57:e9ed411860ed4f2ba0265705b8793d05] in version 4.2. Once we do apply the datasource filter and the option codes, and then try to set the picklist code it empties the picklist values.
So just after the above code, if we do : rbf_setPicklistCode("intName", intCode); // Empties the picklist/select list..
Not sure why.
Any particular reason why?
Iram
Hello,
Any possible resolution for this?
Iram
Hi [mention:78c86023544844079dc6455a4a7a4d57:e9ed411860ed4f2ba0265705b8793d05] ,
I have attached a sample application for your reference. Just go on the "New Page" and check the picklist value there. You'll notice that its empty when I use rbf_setPicklistCode(...).
Let me know if you have any questions.
Cheers.
Iram
[View:/cfs-file/__key/communityserver-discussions-components-files/25/Datasource-Filter-Test-Application_5F00_v1.xml:320:240]
Thank you for sharing app Iram. We confirm that it is a kendo library issue.
On setting value on a filtered datasource, it unsets and reappllies the filter but with logic operator AND. As a result, datasource is now empty.
Will report the same and get it addressed in kendo library. Will comment on expected dates shortly.
If possible, can you consider re-writing filter with a single expression else multiple expressions but with AND logical operator.
Hi [mention:78c86023544844079dc6455a4a7a4d57:e9ed411860ed4f2ba0265705b8793d05] ,
I have changed that filter with an AND operator and it still behaves in the same manner i.e. empties the picklist. Please try it out on the sample application I attached and you can see that for yourself. In the meanwhile, could you please provide a solution for this?
Cheers.
Iram
Iram, request you to remove one of the filter expressions to confirm the logic operator 'AND" filtering issue.
Will work out a sample wherein we do cumstom filtering on kendoDataSource object and not use kendo's filter API to circumvent this issue. Will share this sample shortly.
Iram,
As discussed earlier, have re-done the sample such that we are not leveraging kendoDataSource filter API anymore instead resetting the datasource as per the filter constraints. Please note, that since it is a datasource reset, we cannot access original dataSource values again in this page.
Note: Attached sample is for reference only.
[View:/cfs-file/__key/communityserver-discussions-components-files/25/7180.Datasource-Filter-Test-Application_5F00_v2.xml:100:15]
Ok thanks for the sample application. So if I did want to know what the original values were and perform a filter again based on another condition, how would I go about doing that Siraj?
In that case, before the first reset, make a call to kendoConfig.dataSource.data() and hold on to original dataset.
For any further filtering always start by passing this original dataset in case you want the new filter to be applied afresh on the original dataset.
Thanks Siraj. Will test it out and get back to you if there are any issues.
The temporary workaround works for this issue, however, do we have any tentative dates on which version we can expect this to be fixed in?
Iram.
Hello [mention:78c86023544844079dc6455a4a7a4d57:e9ed411860ed4f2ba0265705b8793d05] ,
Any updates on the dates for this?
Cheers.
Iram