html decode issue with strings in a grid cell

9 posts, 0 answers
  1. Todd
    Todd avatar
    1 posts
    Member since:
    Mar 2015

    Posted 03 Apr 2015 Link to this post

    I am using html.Encode when saving the data in the db.  So in the db I have &lt;&gt; but when I show the data in the grid to the users I want them to see <>.  How can I accomplish decoding the string?

     

    function loadActivity2Grid() {

    intCompanyValue = $('#hdnCompanyID').val();

    if (intCompanyValue != "0" && blnActivityLoaded == false) {

    var ds = new kendo.data.DataSource({
    transport: {
    read: {
    url: "WebService.asmx/loadActivity",
    dataType: "json",
    contentType: "application/json; charset=utf-8",
    type: "GET",
    data: { intCompanyID: intCompanyValue }
    }
    },
    pageSize: 10,
    schema: {
    //data: function (data) {
    // return data.d;
    //},
    data: "d",
    total: "d.length",
    model: {
    fields: {
    intNoteID: { type: "number" },
    ActType: { type: "string" },
    Employee_Name: { type: "string" },
    appt_date: { type: "date" },
    activity_completed_date: { type: "date" },
    OutcomeNotes: { type: "string" },
    ContactName: { type: "string" }
    }
    }
    }
    , sort: ({ field: "appt_date", dir: "desc" })
    });

    $("#grdActivity2").kendoGrid({
    dataSource: ds,
    width: 870,
    filterable: true,
    sortable: {
    mode: "multiple"
    },
    pageable: {
    refresh: true,
    pageSizes: true,
    previousNext: true
    },
    scrollable: false,
    columns: [
    {
    template: '<input type="button" class="btn_small" value="View" onclick="viewActivity(\'#=intNoteID#\');" />', width: 50,
    width: 50
    },

    {
    field: "ActType",
    title: "Type",
    width: 75
    },
    {
    field: "Employee_Name",
    title: "Assigned To",
    width: 125
    },
    {
    field: "appt_date",
    title: "Scheduled<br>Date",
    format: "{0:MM/dd/yyyy}",
    width: 75
    },
    {
    field: "activity_completed_date",
    title: "Date<br>Completed",
    format: "{0:MM/dd/yyyy}",
    width: 75
    },
    {
    field: "OutcomeNotes",
    title: "Outcome/Notes",
    width: 345
    },
    {
    field: "ContactName",
    title: "Contact",
    width: 125
    }
    ]
    });

    }

    }

  2. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2598 posts

    Posted 07 Apr 2015 Link to this post

    Hello Todd,

    You can use the encoded property of the column and set it to true, so the HTML string is displayed as is. Here is an example:

    http://dojo.telerik.com/IfIti

    Regards,
    Kiril Nikolov
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. Diptesh
    Diptesh avatar
    1 posts
    Member since:
    Jun 2011

    Posted 02 Aug 2016 in reply to Kiril Nikolov Link to this post

    Hi,

    How do we handle this for dynamically bound grids? where columns are generated dynamically.

     

  4. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2598 posts

    Posted 03 Aug 2016 Link to this post

    Hi,

    Please open a separate support request with the code of your generated columns and we will be happy to take a look and provide with a possible solution.

    Thanks for the understanding.

    Regards,
    Kiril Nikolov
    Telerik by Progress
     
    Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
     
  5. Stefano
    Stefano avatar
    7 posts
    Member since:
    Oct 2013

    Posted 02 Mar in reply to Kiril Nikolov Link to this post

     

    http://dojo.telerik.com/IfIti

    I can't see any differences with the property set to true and false, I see in both the situations displayed the string "<b>Jane Doe</b>"

    How can I see "Jane Doe" in bold?

  6. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2598 posts

    Posted 02 Mar Link to this post

    Hello,

    Putting markup in data will not affect the presentation. You need to do it in the template:

    http://dojo.telerik.com/IfIti/500

    Regards,
    Kiril Nikolov
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  7. Stefano
    Stefano avatar
    7 posts
    Member since:
    Oct 2013

    Posted 03 Mar in reply to Kiril Nikolov Link to this post

    Ok in this manner it works, my problem is that the data I have to display is stored on database in html.

    It contains text and html for example

    "Warn: look data present in  historical values of <a href='url'>Dow Jones</a>

     

    In this case I can't create a template because datas contains different formats

     

    Thank you

     

    Claudio

     

  8. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2598 posts

    Posted 06 Mar Link to this post

    Hi,

    Then you should not be using template - either display the HTML from the database or use a template, both are not supported at the same time.

    Regards,
    Kiril Nikolov
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  9. Stefano
    Stefano avatar
    7 posts
    Member since:
    Oct 2013

    Posted 09 Mar in reply to Kiril Nikolov Link to this post

    Thank you it works!!
Back to Top