Display grid dataSource schema model field content as HTML hyperlink

1 Answer 99 Views
Data Source Grid
Moslem
Top achievements
Rank 1
Moslem asked on 01 Jun 2023, 01:34 PM

I'm trying to display the content of a Kendo UI Grid dataSource schema model field as an HTML hyperlink. However, I'm getting its content as a string instead.

Here is my code:


var initDSStock = [
  {% for ligne in liste_logements %}
    {% set logement = ligne.logement %}
    {
      log_etat_log: 'test'
    },
  {% endfor %}
];

var dataSource = new kendo.data.DataSource({
  pageSize: 25,
  data: initDSStock,
  schema: {
    model: {
      fields: {
        log_etat_log: { template: '<a href="\\#">#= log_etat_log#</a>' }
      },
    },
  }
});

grid.data("kendoGrid").setDataSource(dataSource);

Is that doable? If so, how should I fix my code? Any idea?

1 Answer, 1 is accepted

Sort by
1
Accepted
Georgi Denchev
Telerik team
answered on 06 Jun 2023, 07:52 AM

Hello, Moslem,

Thank you for the provided code snippet.

The dataSource is used only to manage the data. Additional configurations such as templates are a part of the Grid itself.

In this case, if you wish to use a template while rendering the data, you must utilize the following approach:

var dataSource = new kendo.data.DataSource({
  pageSize: 25,
  data: initDSStock,
  schema: {
    model: {
      fields: {
        log_etat_log: {  }
      },
    },
  }
});

$("#grid").kendoGrid({
 dataSource: dataSource,
 columns: [
  { field: "log_etat_log", template: '<a href="\\#">#=log_etat_log#</a>' }
 ]
})

Best Regards,
Georgi Denchev
Progress Telerik

As of R2 2023, the default icon type will be SVG instead of Font. See this blogpost for more information.
Tags
Data Source Grid
Asked by
Moslem
Top achievements
Rank 1
Answers by
Georgi Denchev
Telerik team
Share this question
or