Hello, 
I saw this Kendo blog post on how to do nested Grids in PHP: http://www.kendoui.com/blogs/teamblog/posts/12-01-18/get_rolling_with_kendo_ui_and_php_ndash_part_1.aspx
I am essentially trying to do the same thing, however I have data coming from Rails and I can't seem to get this example to work with my Rails code. If I need to provide you more code, please let me know.
The project is using nested models - Posts and Comments. Each Post has a 'title' and 'content' field. Each Comment also has a 'title' and 'content' field.
Posts have many Comments and each Comment has a post_id associated with it in the database.
When I render views on the server, I use this path to get comments:
This would render all the comments for Post #1. And the Post JSON would look like this:
If I wanted a specific comment, I would put
The Comment JSON would come out like this:
Since there is a post_id attribute on the Comment, I'm assuming I'd need to filter for that on the sub-grid.... but I'm not sure how to do that.
Here is what I have so far:
Here is the html code that contains the templates:
 
 
 
 
 
 
 
 
Any help is greatly appreciated!
I saw this Kendo blog post on how to do nested Grids in PHP: http://www.kendoui.com/blogs/teamblog/posts/12-01-18/get_rolling_with_kendo_ui_and_php_ndash_part_1.aspx
I am essentially trying to do the same thing, however I have data coming from Rails and I can't seem to get this example to work with my Rails code. If I need to provide you more code, please let me know.
The project is using nested models - Posts and Comments. Each Post has a 'title' and 'content' field. Each Comment also has a 'title' and 'content' field.
Posts have many Comments and each Comment has a post_id associated with it in the database.
When I render views on the server, I use this path to get comments:
http://localhost:3000/posts/1/commentsThis would render all the comments for Post #1. And the Post JSON would look like this:
{"content":"My first post","created_at":"2012-02-07T18:56:16Z","id":1,"title":"Hello","updated_at":"2012-02-07T18:56:16Z"}
If I wanted a specific comment, I would put
http://localhost:3000/posts/1/comments/7The Comment JSON would come out like this:
{"content":"Interesting","created_at":"2012-02-10T22:16:45Z","id":7,"post_id":1,"title":"Great post!","updated_at":"2012-02-10T22:16:45Z"}
Since there is a post_id attribute on the Comment, I'm assuming I'd need to filter for that on the sub-grid.... but I'm not sure how to do that.
Here is what I have so far:
var PostsData = new kendo.data.DataSource({                transport: {                    read: "/posts.json"                }            });                                      $("#posts-grid").kendoGrid({                                 dataSource: PostsData,                            columns: [                {                    field: "title",                    title: "Title"                },                {                    field: "content",                    title: "Content",                                   }],                                 detailTemplate: kendo.template($("#posts-grid-template").html()),                detailInit: detailInit                  });                                      function detailInit(e) {                                 // Reference current row being initialized                var detailRow = e.detailRow;                                 // Create a subgrid for the current                // detail row, getting comments for the post                detailRow.find(".posts-grid").kendoGrid({                    dataSource: {                        transport: {                            read: "comments"                        },                                                 schema: {                            data: "content"                        },                                                 serverFiltering: true,                                                 filter: { field: "post_id", operator: "eq", value: e.data.post_id }                    },                                         columns: [{ title: "Comments", field: "content" }]                })                             }Here is the html code that contains the templates:
<h1>Kendo Grid Test</h1><div id="nav"></div><div id="container">     <!-- The templates below will be placed  here dynamically    -->     </div><!-- TEMPLATES --><script type="text/template" id="users-grid-template">      <p>Users Grid Template</p>      <div id="users-grid"></div>               </script><script type="text/x-kendo-template" id="posts-grid-template">      <div class="comments-grid"></div>   </script><script type="text/template" id="nav-template">  <div>    <ul id="nav_container">        <li><a href="#users">Users</a></li>        <li><a href="#posts">Posts</a></li>    </ul>  </div></script>Any help is greatly appreciated!
2 Answers, 1 is accepted
0
                                
                                                    Phillip
                                                    
                                            
    Top achievements
    
            
                 Rank 1
                Rank 1
            
    
                                                
                                                answered on 11 Feb 2012, 11:50 PM
                                            
                                        Nevermind - I've managed to fix all the issues and now the Kendo grid and nestings are working just fine with Rails.
                                        0
                                
                                                    George
                                                    
                                            
    Top achievements
    
            
                 Rank 1
                Rank 1
            
    
                                                
                                                answered on 15 Feb 2012, 02:00 PM
                                            
                                        How do you fix it?