Kendo UI Grid XML showing data as [object Object]

3 posts, 1 answers
  1. Ghazi
    Ghazi avatar
    2 posts
    Member since:
    Nov 2017

    Posted 28 Nov 2017 Link to this post

    Hi
    I have a Kendo UI grid, that will only display values like [object object]. I have the datasource for the grid working so I know there is data.

    This is my code 

    var ds = new kendo.data.DataSource({
            transport: {
                read: {
                    url: dataUrl + "data_xml.p",
                    contentType: "text/xml",
                    method: "POST",
                    processData: false,
                    dataType: "xml",
                },
                parameterMap: function() {
                    return formxml;
                }
            },
            schema: {
                data: "/ProDataSet/ttCustomers",
                type: "xml"
            },
            model: {
     
                id: "id",
     
                fields: {
     
                    first_name: "first_name/text()",
     
                    last_name: "last_name/text()",
     
                    email: "email/text()",
     
     
                    num_tel: "num_tel/text()",
     
     
                    adresse: "adresse/text()",
                }
            }
     
        });

     

    Data from server : 

       <tt_action>
          <sessionId />
          <action>getdata</action>
          <vstatus>0</vstatus>
          <vmsg />
          <field1 />
          <field2 />
          <field3 />
          <field4 />
       </tt_action>
       <ttCustomers>
          <id>4</id>
          <first_name>Aguistin</first_name>
          <last_name>Scoles</last_name>
          <email>ascoles0@thetimes.co.uk</email>
          <num_tel>+976 222 689 0571</num_tel>
          <adresse>8 Elgar Park</adresse>
       </ttCustomers>
       <ttCustomers>
          <id>5</id>
          <first_name>Jada</first_name>
          <last_name>Brigg</last_name>
          <email>jbrigg1@scribd.com</email>
          <num_tel>+86 114 303 0017</num_tel>
          <adresse>6011 Birchwood Point</adresse>
       </ttCustomers>
       <ttCustomers>
          <id>7</id>
          <first_name>Corenda</first_name>
          <last_name>Bulleyn</last_name>
          <email>cbulleyn2@google.com</email>
          <num_tel>+357 573 337 0942</num_tel>
          <adresse>159 Sycamore Hill</adresse>
       </ttCustomers>
       <ttCustomers>
          <id>8</id>
          <first_name>Nadeen</first_name>
          <last_name>Birkin</last_name>
          <email>nbirkin3@answers.com</email>
          <num_tel>+420 265 225 8304</num_tel>
          <adresse>6600 Manitowish Drive</adresse>
       </ttCustomers>
       <ttCustomers>
          <id>9</id>
          <first_name>Cassy</first_name>
          <last_name>Wickerson</last_name>
          <email>cwickerson4@ucoz.com</email>
          <num_tel>+237 388 473 9219</num_tel>
          <adresse>823 Rockefeller Alley</adresse>
       </ttCustomers>
       <ttCustomers>
          <id>10</id>
          <first_name>Dene</first_name>
          <last_name>Palk</last_name>
          <email>dpalk5@omniture.com</email>
          <num_tel>+62 395 367 4730</num_tel>
          <adresse>2053 Kennedy Center</adresse>
       </ttCustomers>
       <ttCustomers>
          <id>11</id>
          <first_name>Garreth</first_name>
          <last_name>Clayal</last_name>
          <email>gclayal6@sogou.com</email>
          <num_tel>+234 851 283 4750</num_tel>
          <adresse>2243 Manitowish Plaza</adresse>
       </ttCustomers>
       <ttCustomers>
          <id>13</id>
          <first_name>Witty</first_name>
          <last_name>Kilgour</last_name>
          <email>wkilgour7@cmu.edu</email>
          <num_tel>+880 457 881 2601</num_tel>
          <adresse>95 Sage Way</adresse>
       </ttCustomers>
       <ttCustomers>
          <id>14</id>
          <first_name>Abbey</first_name>
          <last_name>Banaszczyk</last_name>
          <email>abanaszczyk8@timesonline.co.uk</email>
          <num_tel>+7 813 501 5869</num_tel>
          <adresse>97 Fieldstone Alley</adresse>
       </ttCustomers>
       <ttCustomers>
          <id>15</id>
          <first_name>Byrom</first_name>
          <last_name>Beachamp</last_name>
          <email>bbeachamp9@buzzfeed.com</email>
          <num_tel>+86 879 807 3783</num_tel>
          <adresse>83369 Golf Drive</adresse>
       </ttCustomers>
       <ttCustomers>
          <id>16</id>
          <first_name>Reeva</first_name>
          <last_name>Moresby</last_name>
          <email>rmoresbya@nba.com</email>
          <num_tel>+93 131 451 6825</num_tel>
          <adresse>5 Sachtjen Parkway</adresse>
       </ttCustomers>
       <ttCustomers>
          <id>17</id>
          <first_name>Hadlee</first_name>
          <last_name>Klisch</last_name>
          <email>hklischb@hostgator.com</email>
          <num_tel>+880 783 928 3370</num_tel>
          <adresse>56 Elka Street</adresse>
       </ttCustomers>
       <ttCustomers>
          <id>18</id>
          <first_name>Marie</first_name>
          <last_name>Mustoo</last_name>
          <email>mmustooc@microsoft.com</email>
          <num_tel>+351 555 677 0044</num_tel>
          <adresse>7016 Hovde Circle</adresse>
       </ttCustomers>
       <ttCustomers>
          <id>20</id>
          <first_name>Georgeanne</first_name>
          <last_name>Zecchii</last_name>
          <email>gzecchiid@etsy.com</email>
          <num_tel>+46 368 291 6723</num_tel>
          <adresse>10799 Londonderry Drive</adresse>
       </ttCustomers>
       <ttCustomers>
          <id>21</id>
          <first_name>Norah</first_name>
          <last_name>Levane</last_name>
          <email>nlevanee@usa.gov</email>
          <num_tel>+86 636 328 8366</num_tel>
          <adresse>20976 Hanover Alley</adresse>
       </ttCustomers>
       <ttCustomers>
          <id>22</id>
          <first_name>Timi</first_name>
          <last_name>Abramson</last_name>
          <email>tabramsonf@omniture.com</email>
          <num_tel>+30 973 316 0947</num_tel>
          <adresse>461 Bellgrove Way</adresse>
       </ttCustomers>
       <ttCustomers>
          <id>23</id>
          <first_name>Kirsten</first_name>
          <last_name>Hearnden</last_name>
          <email>khearndeng@ca.gov</email>
          <num_tel>+86 818 429 5160</num_tel>
          <adresse>0 Melvin Trail</adresse>
       </ttCustomers>
       <ttCustomers>
          <id>24</id>
          <first_name>Tommie</first_name>
          <last_name>Haggarty</last_name>
          <email>thaggartyh@shutterfly.com</email>
          <num_tel>+502 320 246 3017</num_tel>
          <adresse>76 Parkside Parkway</adresse>
       </ttCustomers>
       <ttCustomers>
          <id>25</id>
          <first_name>Orella</first_name>
          <last_name>Gossan</last_name>
          <email>ogossani@mysql.com</email>
          <num_tel>+86 435 661 2497</num_tel>
          <adresse>0 Blue Bill Park Parkway</adresse>
       </ttCustomers>
       <ttCustomers>
          <id>26</id>
          <first_name>Melly</first_name>
          <last_name>Loidl</last_name>
          <email>mloidlj@state.tx.us</email>
          <num_tel>+376 969 321 3040</num_tel>
          <adresse>59541 Forest Hill</adresse>
       </ttCustomers>
       <ttCustomers>
          <id>28</id>
          <first_name>Yettie</first_name>
          <last_name>Petranek</last_name>
          <email>ypetranekk@clickbank.net</email>
          <num_tel>+970 458 555 6703</num_tel>
          <adresse>3 Montana Avenue</adresse>
       </ttCustomers>
       <ttCustomers>
          <id>29</id>
          <first_name>Natal</first_name>
          <last_name>Bauman</last_name>
          <email>nbaumanl@diigo.com</email>
          <num_tel>+86 418 984 0016</num_tel>
          <adresse>03252 Division Plaza</adresse>
       </ttCustomers>
       <ttCustomers>
          <id>30</id>
          <first_name>Joela</first_name>
          <last_name>Bendon</last_name>
          <email>jbendonm@yolasite.com</email>
          <num_tel>+357 836 602 1041</num_tel>
          <adresse>056 Caliangt Hill</adresse>
       </ttCustomers>
       <ttCustomers>
          <id>31</id>
          <first_name>Timothy</first_name>
          <last_name>Antonsen</last_name>
          <email>tantonsenn@123-reg.co.uk</email>
          <num_tel>+86 767 723 8152</num_tel>
          <adresse>3 Tennessee Trail</adresse>
       </ttCustomers>
       <ttCustomers>
          <id>32</id>
          <first_name>Joye</first_name>
          <last_name>Bourgeois</last_name>
          <email>jbourgeoiso@t-online.de</email>
          <num_tel>+33 398 217 3274</num_tel>
          <adresse>14377 Spenser Crossing</adresse>
       </ttCustomers>
    </ProDataSet>

     

    Grid code :

     

    $('#customers-list').kendoGrid({
              dataSource: ds,
              toolbar: ["create", "save", "excel"],
              excel: {
                  fileName: "Export.xlsx"
              },
              sortable: true,
              columns: [{
                  field: "first_name",
                  title: "Nom",
              }, {
                  field: "last_name",
                  title: "Prénom"
              }, {
                  field: "email",
                  title: "Adresse Email",
              }, {
                  field: "num_tel",
                  title: "Numéro de téléphone"
              }, {
                  field: "adresse",
                  title: "Adresse"
              }, {
                  command: ["edit", "destroy"],
                  title: " ",
                  width: "300px"
              }],
              editable: "popup",
              pageable: {
                  pageSize: 5,
              }
          });
  2. Answer
    Tsvetina
    Admin
    Tsvetina avatar
    2481 posts

    Posted 29 Nov 2017 Link to this post

    Hi Ghazi,

    Your code is overall correct with one minor exception causing the problem. The model is defined outside of the schema configuration, so it is like there is no model definition at all. Just move the model inside the schema and the columns will populate correctly:
    var ds = new kendo.data.DataSource({
            transport: {
                read: {
                    url: dataUrl + "data_xml.p",
                    contentType: "text/xml",
                    method: "POST",
                    processData: false,
                    dataType: "xml",
                },
                parameterMap: function() {
                    return formxml;
                }
            },
            schema: {
                data: "/ProDataSet/ttCustomers",
                type: "xml",
                model: {
                    id: "id",
                    fields: {
                        first_name: "first_name/text()",
                        last_name: "last_name/text()",
                        email: "email/text()",
                        num_tel: "num_tel/text()",
                        adresse: "adresse/text()",
                    }
                }
            }
      
        });


    Regards,
    Tsvetina
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Ghazi
    Ghazi avatar
    2 posts
    Member since:
    Nov 2017

    Posted 29 Nov 2017 in reply to Tsvetina Link to this post

    Hi Tsvetina

    It's working fine now, Thanks!

Back to Top