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

Grid Model and fields.

1 Answer 488 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chatra
Top achievements
Rank 1
Chatra asked on 02 Jun 2014, 09:09 PM
Hi I have my objects defined as below on server. I am just looking for how to define schema ,model and fields for below objects.



public class AgentModel //shown in a agent Grid
    {
      public int AgentID { get; set; }
      public string Name { get; set; } //column is shown in agent grid add/edit popup as a field on  Tabstrip1
      public StateModel State { get; set; } //similar to above field
      public Boolean IsActive { get; set; } //similar to above field
      public List<AgentWiterModel> AgentWiters { get; set; } // Shown in AgentWriter grid on Tabstrip2 when add/edit of master Agent grid.
 
    }
public class AgentWriterModel
    {
        public int AgentID { get; set; } //read only
        public string AgencyID { get; set; } 
        public WriterModel Writer { get; set; }
    }
public class WriterModel
   {
       public int WriterID{get;set;} //want to bind this value on popup
       public string Code{get;set;}
       public string Name { get; set; } //want to bind and show on popup
       public Boolean IsActive { get; set; }
        
   }

schema: {
       model: {
                id: "AgentID",
                Name: "Name",
                State: "State",
                IsActive: "IsActive",
                AgentWiters: "AgentWiters",
                fields: {
                    AgentID: { type: "int", validation: { required: true} },
                    Name: { type: "string", validation: { required: true} },
                    State: { defaultValue: { Value: "", Text: "" }, validation: { required: true} },
                    IsActive: { type: "boolean", defaultValue: true }
                   }
             }
        }
 
 
On Edit of above model in a agent grid ;will open a below model in a new grid .Which I am facing difficulty to map perfect data-model.
 
schema: {
                    model: {
                        id: "Writer.WriterID",
                        Writer:"Writer",
                        AgentID: "AgentID",
                        AgencyID: "AgencyID",
                        fields: {
                           WriterID: { type: "string", defaultValue: ""},
                            Writer: { defaultValue: { WriterID: "", Name: ""} },
                            AgentID: { type: "int" },
                            AgencyID: { type: "string", validation: { required: true} },
                        }
                    }
                }
 
 
Here I want the Writer grid to map with columns like Writer.WriterID ,Writer.Name and AgencyID to add or edit into Agentwriter Grid.

columns: [
             { field: "AgentID", title: "AgentID", hidden: true },
           //{ field: "Writer.WriterID", title: "WriterID", hidden: true },
             { field: "Writer.Name", title: "WriterName" },
             { field: "AgencyID", title: "Agency ID"},
             { field: "Writer.IsActive", title: "Status", hidden: true },
          ]

//getting error with unable to get value of property for below popup template for writer drop down .
//writer is Drop Down to select Writer and bind text and value fields as separate columns in agentwriter Grid

<table>
         <tr>
         <td>
           <label for="Writer" class="required">Name * :</label>
         </td>
         <td>
           <input id="Writer" name="Writer"  data-bind="value:Writer" /> 
        </td>
  </tr>
  <tr>
         <td>  
          <label for="WriterID" class="required">Writer ID * :</label>
         </td>
         <td>
           <input type="text" id="WriterID" class="k-input k-textbox" name="WriterID"  data-bind="value:Writer.WriterID"   />            
         </td>
  </tr>
  <tr>
          <td>  
           <label for="AgencyID" class="required">Agency ID * :</label>
         </td>
         <td>
           <input type="text" id="AgencyID" class="k-input k-textbox" name="AgencyID"  data-bind="value:AgencyID"  />            
        </td>
  </tr>
</table>

Please let me know any info required.

Thanks
Chatrapathi chennam

1 Answer, 1 is accepted

Sort by
0
Accepted
Petur Subev
Telerik team
answered on 04 Jun 2014, 04:26 PM
Hello Chatra,

Editing of a nested collection is not supported by the Grid widget and we strongly recommend to create hierarchy of Grids like demonstrated here:

http://www.telerik.com/support/code-library/grid-ajax-hierarchy-editing 

Each level of the Grid should have separate dataSource defined which will be used when there are changes applied to the corresponding Grid level.

Nevertheless there is a work-around which you can use (however please keep in mind it has its limitations and it is not that flexible). You can check the example here:

http://www.telerik.com/support/code-library/grid-popup-editing-navigation-property-collection-with-nested-grid

Kind Regards,
Petur Subev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Chatra
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Share this question
or