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

[Solved] Bind to XElement - razor syntax

5 Answers 22 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Greg
Top achievements
Rank 1
Greg asked on 20 Feb 2012, 05:18 PM

I can't figure this out. I have the results of a linq query and want to display them in a table.

This is what the controller returns:

return View(new GridModel<XElement>
            {
                Data = ci
            });

This is what is in the view:

@{
    ViewBag.Title = "Home Page";
}
 
<h2>@ViewBag.Message</h2>
 
@model IEnumerable<System.Xml.Linq.XElement>
@{Html.Telerik().Grid(Model)
        .Name("Issues")
        .Columns(cols => {
            cols.Bound(c => c.Attribute("Issue").Value).Template(
                 
@<text>
Attribute("Issue").Value
</text>
                );
        })
        .DataBinding(db => db.Ajax().Select("_ClientLoading", "Home").OperationMode(GridOperationMode.Client))
        .Filterable()
        .Sortable()
        .Groupable()
        .Render();   
             
}

5 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 22 Feb 2012, 08:51 AM
Hello,

What is the problem which you are currently facing? I couldn't understand that from what you have posted. Please elaborate.

All the best,
Atanas Korchev
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Greg
Top achievements
Rank 1
answered on 22 Feb 2012, 05:46 PM
Internal server error 500 and no data.

Do you have any existing examples of using XElements? Doesn't seem like I should need to re-invent the wheel for something that's been done before.
0
Atanas Korchev
Telerik team
answered on 22 Feb 2012, 06:44 PM
Hi,

 No, we currently don't have any existing examples for binding to XElements. Could you check the server response when server error 500 is shown? You can use a HTTP sniffer tool such as Fiddler or Firebug to do this. In that response the full stack trace of the exception would be shown. I suspect that JSON serialization of XElement is not supported by ASP.NET MVC hence the exception.

Regards,
Atanas Korchev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now.
0
Greg
Top achievements
Rank 1
answered on 22 Feb 2012, 11:12 PM
My data is already in XML so I don't want to go through all sorts of [de]serialization. Plan 2 is to feed the table by simply doing a get for some XML. How can I feed the grid directly with XML or through Javascript calls to add grid rows.
0
Atanas Korchev
Telerik team
answered on 23 Feb 2012, 08:27 AM
Hi,

 Telerik Grid for ASP.NET MVC does not support binding to raw XML data. You also cannot add rows on the client side.

Regards,
Atanas Korchev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now.
Tags
Grid
Asked by
Greg
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Greg
Top achievements
Rank 1
Share this question
or