MVC3 GRID + ORM STORED PROCEDURE + MySQL

4 posts, 0 answers
  1. Sander
    Sander avatar
    17 posts
    Member since:
    Apr 2008

    Posted 31 Jul 2011 Link to this post

    hi Folks,

    I am new to MVC and i have a MVC 3 Telerik project and try to display a grid with a Telerik ORM Stored Procedure call to MySQL.

    My problem is:
    that the GetDetailsChannel is of type Object[] and not a model, sdo how do i bind this object to my Grid or how do make my ORM Stored Procedure of type Model?

    My Controler is:
            public ActionResult Channels()
            {
                var Channels = new IMS_ORM_Telerik.EntitiesModel();
                return View(Channels.GetDetailsChannel(1));
            }

    My View is:
    @model IEnumerable<IMS_ORM_Telerik.Channel>
      @(Html.Telerik().Grid(Model)
    .Name("Grid")
    .Columns(columns =>
    {
         columns.Bound(o => o.Channel_id).Title("Id").Width(50);
         columns.Template(
                    @<text>                    
                        <img src="/images/@item.Channel_image"/>           
                    </text>)
                    .Title("Icon").Width(50);
        columns.Bound(o => o.Channel_type);

        columns.Template(
            
      @<text>
      @Html.ActionLink("Edit", "Prepare/Television", new { item.Channel_id })
         @Html.ActionLink("Delete", "Prepare/Television", new { item.Channel_id })
                   
                    </text>).Title("Actions").Width(100);




        columns.Bound(o => o.Channel_type).Visible(false)



                      .FooterTemplate(@<text>Total Count: @item.Count</text>)
                      .GroupFooterTemplate(@<text>Count: @item.Count</text>);
    })
    .Sortable()
    .Filterable()
    .Pageable()
    .Groupable())

    Hope anyone can help me.

    Thanks Sander
  2. PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 03 Aug 2011 Link to this post

    Hi Sander,

     You can use our newly introduced ADO.API. With that api you are able to materialize not only to persistent types but to POCOs as well. Please have a look in our documentation for more information.
    Please do not hesitate to contact us back should you have any further questions or problems.

    Kind regards,
    Petar
    the Telerik team
    Want to use Telerik OpenAccess with SQL Azure? Download the trial version today. 
  3. DevCraft banner
  4. Sander
    Sander avatar
    17 posts
    Member since:
    Apr 2008

    Posted 03 Aug 2011 Link to this post

    Thanks for your answer I tried your solution and it works the only thing is that is display all the columns it gives back and i just want to show a few of them, i set the autogeneratecolumns to false.

    Thanks

    Sander
  5. Ivailo
    Admin
    Ivailo avatar
    318 posts

    Posted 05 Aug 2011 Link to this post

    Hi Sander,

    You should still be able to achieve that by defining column templates in the View, as you were doing in the sample code you have sent initially. There is detailed information for binding columns in the ASP.NET MVC grid documentation.

    If you have problems configuring those templates, you can send the view and the controller and we can try to limit the columns for you as an example.

    I am looking forward to your feedback.


    All the best,
    Ivailo
    the Telerik team
    Want to use Telerik OpenAccess with SQL Azure? Download the trial version today. 
Back to Top