This is a migrated thread and some comments may be shown as answers.

Problems with getting data when ' is in text

1 Answer 359 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jeroen
Top achievements
Rank 1
Jeroen asked on 25 Mar 2019, 09:51 AM

I have a grid which contains an adres ticket, some adresses contain a special character like ' 

When I want to get the data from the item when I click an icon on the record, I don't get the correct data:

This is my javascript to load the grid (it is placed in a div)

function loadConnectionsGrid() {
        connectionsGrid = $("#connectionsGrid").kendoGrid({
            selectable: "row",
            filterable: true,
            pageable: {
                refresh: true,
                pageSizes: [10, 20, 50, 100],
                buttonCount: 5
            },
            resizable: true,
            columnMenu: true,
            sortable: true,
            reorderable: true,
            columns: [{
                field: "EAN",
                title: "EAN",
                width: "140px"
            }, {
                field: "Discipline",
                title: "Discipline",
                filterable: { multi: true },
                width: '100px'
            }, {
                field: "StreetName",
                title: "Straat"
            }, {
                field: "PostalCode",
                title: "Postcode",
                width: '100px'
            }, {
                field: "BuildingNumber",
                title: "Huisnummer",
                width: '100px'
            }, {
                field: "BuildingNumberSuffix",
                title: "Toevoeging",
                width: '100px'
            }, {
                encoded: true,
                field: "CityName",
                title: "Plaats",
                width: "140px"
            }, {
                title: " ",
                template: "#=selectAddressAction(data)#",
                width: '25px'
            }]
        }).data("kendoGrid");
    }

In my case it's about column Cityname (I already tries encoded: true as you can see)

When I click the icon on the record this function fires: 

 function initializeCreateConnectionModal(e) {

        $("#btn-create-and-assign").show();
        $("#btn-create-case").show();
        $("#createConnectionModal-success").hide();
        $("#createConnectionModal-error").hide();

        enexis.services.tablerecords.getData({ Tables: [{ Name: "ANL001" }] }, getAanleidingCallback);

        var item = $(e.relatedTarget).data('item');
        loadSelectedConnectionsGridData(item);
    }

 

 When I'm trying to get the item (the bold line) In this case I don't get an object with the data like Screenshot01.png

But I get a string (Screenshot02.png)

 

 

1 Answer, 1 is accepted

Sort by
0
Alex Hajigeorgieva
Telerik team
answered on 27 Mar 2019, 09:40 AM
Hi, Jeroen,

Thank you for giving Kendo UI a test run.

The recommended way of getting the data item bound to a grid row is with the dataItem() method:

https://docs.telerik.com/kendo-ui/api/javascript/ui/grid/methods/dataitem

When the grid dataItem() method is used, there are no issues with the apostrophe in the text. Here is a sample Dojo demonstrating that:

https://dojo.telerik.com/@bubblemaster/UhOyuQaD/2

In addition to that, the title of the columns should be declared only when it differs from the field's name. If it does not, you can skip it and the field name will be used.

Let us know in case you have further questions.

Regards,
Alex Hajigeorgieva
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Grid
Asked by
Jeroen
Top achievements
Rank 1
Answers by
Alex Hajigeorgieva
Telerik team
Share this question
or