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

Field Name with Space and Other Than Numeric Creating Issues to Load the Grid

8 Answers 1004 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chetan
Top achievements
Rank 1
Chetan asked on 19 Dec 2011, 07:09 AM
While binding the Grid to columns with below works well and fine and loads the grid:

columns: [
                                { field: "ID", title: "ID" },
                                { field: "Name", title: "First Name" },
                                { field: "City_Name", title: "City" },
                                { field: "Email", title: "Email" },
                                { field: "pincode", title: "pincode" }

                             ]

But when we add the below columns (any of them), then there is any issue. There is no issue with JSON. We found that any field name with spaces or numeric value and special characters does not load the grid at all

Scenario 1 (does not load the Grid)

columns: [
                                { field: "ID", title: "ID" },
                                { field: "Name", title: "First Name" },
                                { field: "City_Name", title: "City" },
                                { field: "Email", title: "Email" },
                                { field: "pincode", title: "pincode" },
                                { field: "Last Name", title: "Last Name" }
                             ]

Scenario 2 (does not load the Grid)

columns: [
                                { field: "ID", title: "ID" },
                                { field: "Name", title: "First Name" },
                                { field: "City_Name", title: "City" },
                                { field: "Email", title: "Email" },
                                { field: "pincode", title: "pincode" },
                                { field: "Mob.1", title: "Mobile" }
                             ]

Seems to be a bug, or are we doing something wrong ?

8 Answers, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 20 Dec 2011, 01:53 PM
Hello Chetan,

This is expected behavior. Field names should not contain spaces and/or dots.

Regards,
Nikolay Rusev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Alberto
Top achievements
Rank 1
answered on 13 Mar 2013, 08:06 PM
Hi Nikolay,

I'm loading a grid from a DataTable. This DataTable is loaded from a table on SQL Server, so I will probably have column names containing spaces. Is it still a problem for the last version of Kendo?

Thanks
0
Nikolay Rusev
Telerik team
answered on 15 Mar 2013, 08:32 AM
Hello Alberto,

Here is how to configure the grid in order to bind columns with spaces in the field names: http://jsbin.com/evapes/3/edit 

This configuration is supported with Q1 2013 Beta release of Kendo UI Web.

Regards,
Nikolay Rusev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Ayette
Top achievements
Rank 1
answered on 01 Jun 2014, 07:11 AM
Tried Nikolav Rusey suggested but still not working for second field (First Name).

http://jsbin.com/wemun/2/


$(function() {
  $("#grid").kendoGrid({
    dataSource: {
      data: [
              { "Title": "Mr.", "First Name": "Name 1"},
              { "Title": "Dr.", "First Name": "Name 2"},
              { "Title": "Dr.", "First Name": "Name 3"}
            ]
    },
    columns: [
               {field : "Title", title: "Title"},
               {Field: "First Name", title: "First Name"}
             ]
  });
});
0
Ayette
Top achievements
Rank 1
answered on 01 Jun 2014, 07:18 AM
Correction : http://jsbin.com/wemun/4/

$(function() {
  $("#grid").kendoGrid({
    dataSource: {
      data: [
              { "Title": "Mr.", "First Name": "Name 1"},
              { "Title": "Dr.", "First Name": "Name 2"},
              { "Title": "Dr.", "First Name": "Name 3"}
            ]
    },
    columns: [
               {field : "Title", title: "Title"},
               {field: "First Name", title: "First Name"}
             ]
  });
});
0
Nikolay Rusev
Telerik team
answered on 03 Jun 2014, 08:28 AM
Hello Ayette,

You are not using correct syntax in order to bind the grid correctly. Please revisit the fiddle posted in my previous post, especially the `foo bar` column.

Regards,
Nikolay Rusev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Ayette
Top achievements
Rank 1
answered on 03 Jun 2014, 09:03 AM
Oh thanks did not see the '["Field Name"]'
0
Justim
Top achievements
Rank 2
answered on 20 Aug 2015, 04:13 PM

If you would like to use format strings on columns with spaces you also need to set the a model definition in the dataSource, and a "from" configuration for the field with a space, which will create a mapping between a spaced and non-spaced field name.

http://jsbin.com/jodukitata/edit?html,js,output

http://docs.telerik.com/kendo-ui/api/javascript/data/model#methods-Model.define

Please keep in mind that using fields with spaces is not recommended and you may stumble upon other unexpected issues as well.​

Tags
Grid
Asked by
Chetan
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Alberto
Top achievements
Rank 1
Ayette
Top achievements
Rank 1
Justim
Top achievements
Rank 2
Share this question
or