Distinction Between dataTextField and model.fields.text.from in Kendo UI TreeView

Sharing in case it assists anyone. Is it feasible to transfer the dependency jars to HDFS for executing a thin jar without them? Unfortunately, the Operation and Maintenance Engineers have prohibited me from transferring the jar to the Flink lib folder. However, I have no issues reading other files that are saved in comparable directories.


Question:

My HierarchicalDataSource relies on the

title

field to supply the text for each node. However, the TreeView component requires the use of

text

for this purpose. To align the two, there are two possible approaches.

  1. Transferring

    dataTextField

    and

    : 'title'

    codes to the constructor of

    treeview

    .
  2. The process involves utilizing

    schema.model:

    and

    fields.text.from

    , where

    schema: { model: { fields: { text: { from: 'title' } },... }

    denotes the specific field from the original record that will be used to populate the Model field.

Given the documentation for

options.fields

contains grammatical errors, which approach is the recommended one?


Solution:

By selecting the

dataTextField

feature, it becomes possible to refer to the node’s properties using their original names from the data. This applies specifically to

title

.

var myHDS = new kendo.data.HierarchicalDataSource({
    transport: {
        read: function (options) {
            var node = myHDS.get(options.data.id);
            // node.title is accessible here
        }
    },
    schema: {
        model: {
            id: 'id',
            hasChildren: 'children'
        }
    }
});
$("#tree-container").kendoTreeView({
    dataSource: myHDS,
    dataTextField: 'title'
})

Changing

schema.model.fields.text.from

to

title

necessitates accessing the node’s

title

attribute, which should be labeled as

node.text

.

var myHDS = new kendo.data.HierarchicalDataSource({
    transport: {
        read: function (options) {
            var node = myHDS.get(options.data.id);
            // node.title is accessible here
        }
    },
    schema: {
        model: {
            fields: {
                text: {
                    from: 'title'
                }
            },
            id: 'id',
            hasChildren: 'children'
        }
    }
});
$("#tree-container").kendoTreeView({
    dataSource: myHDS
})

Frequently Asked Questions