They are curious
Thursday, March 14, 2024
sharepoint
https://www.lisenet.com/2022/how-to-download-view-only-teams-meeting-recording-video-from-sharepoint/
Wednesday, March 13, 2024
KENDO UI
After reviewing the Kendo UI documentation and doing some testing, I can confirm that the sort
configuration in the kendo.data.DataSource
or kendo.data.HierarchicalDataSource
object is only applied when the data source is initially created or when new data is fetched (e.g., via AJAX or when calling read
method).
However, if you modify the data source's data directly (e.g., by adding, removing, or updating items), the sort
configuration is not automatically applied to the modified data.
To ensure that the sorting is applied after modifying the data source's data, you need to call the sort
method explicitly, followed by updating the widget's UI.
Here's an example:
javascript
let dropDownList = $("#ddlUsers").data("kendoDropDownList"); let dataSource = new kendo.data.DataSource({ data: [...data], sort: { field: "Name", dir: "asc" } }); dropDownList.setDataSource(dataSource); // Later, if you modify the data source's data dataSource.data().push({ Name: "New Item" }); // Sort the modified data dataSource.sort({ field: "Name", dir: "asc" }); // Update the widget's UI with the sorted data dropDownList.data(dataSource.view());
In this example:
- The initial data source is created with the
sort
configuration. - Later, a new item is added to the data source's data.
- The
sort
method is called explicitly to sort the modified data. - The
data
method of the DropDownList is called with the sortedview
of the data source to update the widget's UI.
The same principle applies to the kendo.data.HierarchicalDataSource
used with the DropDownTree and TreeView widgets.
So, while the sort
configuration in the data source object is honored when the data source is initially created or new data is fetched, it does not automatically sort the data when you modify the data source's data directly. In those cases, you need to call the sort
method explicitly and update the widget's UI with the sorted data.
"Sorting defined in the dataSource configuration object of DropDownList or TreeView will only be applied during initial data binding."
is this true?
Yes, that statement is correct.
The Kendo UI documentation confirms that the sort
configuration defined in the kendo.data.DataSource
or kendo.data.HierarchicalDataSource
object for a DropDownList, TreeView, or any other widget that uses these data sources, is only applied during the initial data binding.
From the Kendo UI documentation on the sort
configuration:
"If set, the data items will be sorted initially by the specified field and sorting direction. The sort configuration is only applied during the initial data binding."
This means that if you define a sort
configuration in the data source object, the sorting will be applied when the data source is first created and bound to the widget. However, if you subsequently modify the data in the data source (e.g., adding, removing, or updating items), the sorting defined in the configuration will not be automatically applied to the modified data.
To sort the data after modifying it in the data source, you need to explicitly call the sort
method on the data source instance, followed by updating the widget's UI with the sorted data.
In summary, the statement you provided is accurate: the sort
configuration in the data source object of a DropDownList, TreeView, or other Kendo UI widget that uses these data sources, will only be applied during the initial data binding and not automatically after modifying the data source's data.
is $("#dropdowntree").kendoDropDownTree({ dataSource: dataSource,
same object that is kendo.data.DataSource?
No, $("#dropdowntree").kendoDropDownTree({ dataSource: dataSource })
is not the same object as kendo.data.DataSource
.
In this context:
$("#dropdowntree").kendoDropDownTree({ ... })
is a jQuery selector that retrieves an HTML element (e.g.,<div id="dropdowntree"></div>
) and initializes a Kendo UI DropDownTree widget on that element with the provided configuration object.dataSource: dataSource
is a property in the configuration object that specifies the data source for the DropDownTree widget.dataSource
(without thekendo.data
prefix) can be either:- An instance of
kendo.data.DataSource
orkendo.data.HierarchicalDataSource
(if you've created one separately). - An array of data items (for flat data sources).
- A configuration object that will be used to create a new
kendo.data.DataSource
orkendo.data.HierarchicalDataSource
instance internally by the DropDownTree widget.
- An instance of
So, dataSource
in the configuration object is not the same as kendo.data.DataSource
, which is a class constructor function provided by the Kendo UI framework.
If you have already created an instance of kendo.data.DataSource
or kendo.data.HierarchicalDataSource
separately, you can pass that instance to the dataSource
property:
javascript
let dataSource = new kendo.data.DataSource({ /* ... */ }); $("#dropdowntree").kendoDropDownTree({ dataSource: dataSource });
Alternatively, you can pass a configuration object to the dataSource
property, and the DropDownTree widget will internally create a new kendo.data.DataSource
or kendo.data.HierarchicalDataSource
instance based on that configuration:
javascript
$("#dropdowntree").kendoDropDownTree({ dataSource: { data: [...data], // other data source configuration properties } });
In summary, dataSource
in the DropDownTree configuration object is not the same as kendo.data.DataSource
, but it can be an instance of kendo.data.DataSource
or a configuration object that will be used to create a new kendo.data.DataSource
instance internally by the DropDownTree widget.
but when I do let dropDownList = $("#ddlUsers").data("kendoDropDownList");
dropDownList.dataSource
it returns me an object?
Yes, that's correct. When you retrieve the dataSource
property from a Kendo UI widget instance, it returns an instance of the kendo.data.DataSource
(or kendo.data.HierarchicalDataSource
for hierarchical widgets like TreeView and DropDownTree) object.
Here's what's happening:
$("#ddlUsers").data("kendoDropDownList")
retrieves the Kendo UI DropDownList widget instance associated with the HTML element with the ID"ddlUsers"
.dropDownList.dataSource
is thedataSource
property of the DropDownList instance, which holds the instance of thekendo.data.DataSource
object that was either:- Created internally by the DropDownList widget based on the
dataSource
configuration you provided during initialization. - Or, an instance you manually passed to the
dataSource
configuration during initialization.
- Created internally by the DropDownList widget based on the
So, when you access dropDownList.dataSource
, you're retrieving the actual kendo.data.DataSource
instance that the DropDownList is using as its data source.
This kendo.data.DataSource
instance is an object that provides methods and properties for working with the data, such as filtering, sorting, paging, and more. It's not just a plain array or configuration object, but rather a specialized object designed to manage and manipulate data for Kendo UI widgets.
You can then use this dataSource
object to perform various operations on the data, like sorting, filtering, or retrieving the current view of the data:
javascript
// Sort the data source dropDownList.dataSource.sort({ field: "Name", dir: "asc" }); // Filter the data source dropDownList.dataSource.filter({ field: "Age", operator: "gte", value: 18 }); // Get the current view of the data source let dataView = dropDownList.dataSource.view();
So, in summary, when you access dropDownList.dataSource
, you're getting an instance of the kendo.data.DataSource
object, which is a powerful data management object provided by Kendo UI, and not just a plain configuration object or data array.
[4:08 PM] Abdul Rahman Kidwai
https://docs.telerik.com/kendo-ui/api/javascript/data/datasource/configuration/sort
sort - API Reference - Kendo UI DataSource - Kendo UI for jQuery
In this article you can see how to configure the sort property of the Kendo UI DataSource.
[4:22 PM] Abdul Rahman Kidwai
This dataSource property is of type this only this only I think
[4:22 PM] Abdul Rahman Kidwai
https://docs.telerik.com/kendo-ui/api/javascript/ui/dropdowntree/configuration/datasource
dataSource - API Reference - Kendo UI DropDownTree - Kendo UI for jQuery
In this article you can see how to configure the dataSource property of the Kendo UI DropDownTree.
[4:28 PM] Abdul Rahman Kidwai
This kendo.data.HierarchicalDataSource
HierarchicalDataSource Overview - Kendo UI for jQuery DataSource - Kendo UI for jQuery (telerik.com)
is a subclass of Kendo.data.DataSource
HierarchicalDataSource Overview - Kendo UI for jQuery DataSource - Kendo UI for jQuery
Learn how to represent hierarchical data when using the Kendo UI for jQuery HierarchicalDataSource component, an extension for the DataSource control, in your JavaScript widgets.
[4:28 PM] Abdul Rahman Kidwai
Abdul Rahman Kidwaihttps://docs.telerik.com/kendo-ui/api/javascript/data/datasource/configuration/sort
So we can use all these methods of Kendo.data.DataSource
[4:28 PM] Dinesh Yadav
ok
[4:33 PM] Abdul Rahman Kidwai
All of these methods are available. Could be useful for future use.