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

problem binding XML to Grid , when xml node having duplicate elements

2 Answers 63 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Selvamani
Top achievements
Rank 1
Selvamani asked on 08 Feb 2013, 10:45 AM
my sample xml is 

<id> 
  <r rn="1">
   <vw n="address" v="Mycomp" />
   <vw n="description" v="AdminOU" />
   <vw n="identifier" v="1" />
 </r>
 <r rn="2">
     <vw n="address" v="Mycomp" />
   <vw n="description" v="SASDesignOU" />
   <vw n="identifier" v="2" />
 </r>
 </id>

i have 3 columns in my grid , 
{
                type: 'xml',
                data: '/id/r/vw',
                model: {
                    id: 'rn',
                    fields: {
                        id:     '@rn',
                      address:   { field:    '@v'},
                      description: '@v',
      identifier  : '@v'
                        
                    }
                }
            }

since my <element> having duplicated in the <r> node, the output is coming as

address        description     identifire
---------         --------------     -----------
Mycomp       Mycomp         Mycomp

AdminOU       AdminOU       AdminOU
  1                    1                    1

like that is coming, but i need the grid row values should be [ mycomp, adimin ou, 1],  in <vw> element i have @n, based upon the attribute value can i load the grid as i wish.. can u please help me regarding this

2 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 11 Feb 2013, 08:27 AM
Hi Selvamani,

I'm afraid that this scenario is not fully supported as the columns are described by multiple elements with same name. Although you may use schema similar to the following to described this:

           type: 'xml',
   data: '/id/r',
   model: {
          fields: {
            rn: '@rn',
            address:{ field: '/vw/[0]/@v'},
            description: '/vw/[1]/@v',
            identifier  : '/vw/[2]/@v'           
          }
        }

I suggest you to consider either combining column values as attributes of a single element or renaming the elements with names of the separate fields.All the best,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Selvamani
Top achievements
Rank 1
answered on 11 Feb 2013, 08:55 AM
Thanks Rosen, that is the format of the response xml from the server side. its working fine now... thanks again
Tags
Grid
Asked by
Selvamani
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Selvamani
Top achievements
Rank 1
Share this question
or