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

[Solved] Grid Toolbar Insert button behavior problem

0 Answers 103 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.
Jack Ma
Top achievements
Rank 1
Jack Ma asked on 12 Apr 2010, 05:43 AM
Hi
   I'm using VS2008 plus telerik MVC extension. I have two grids on a page that the first show role list and the second show the users in the selected role. Below are the grid setting for two grids,
<% if (Model.Roles != null) 
   { %> 
<h2>Roles</h2> 
 
<%= Html.Telerik().Grid((IEnumerable<PlatformRole>)Model.Roles) 
        .Name("Roles") 
        .ToolBar(commands => commands.Insert()) 
        .DataKeys(keys => keys.Add(c => c.RoleName)) 
        .DataBinding(dataBinding =>  
        { 
            dataBinding.Ajax() 
            .Select("MaintainPlatformRoles", "PlatformAdministration", new { ActionName = "Select" }) 
            .Insert("MaintainPlatformRoles", "PlatformAdministration", new { ActionName = "Insert" }) 
            .Update("MaintainPlatformRoles", "PlatformAdministration", new { ActionName = "Edit" }) 
            .Delete("MaintainPlatformRoles", "PlatformAdministration", new { ActionName = "Delete" }); 
        }) 
        .Columns(columns => 
        { 
            columns.Bound(c => c.RoleName).Width(130); 
            columns.Command(commands => 
            { 
                commands.Edit(); 
                commands.Delete(); 
            }).Width(180).Title("Commands"); 
        }) 
        .Pageable() 
        .Sortable() 
        .Selectable() 
        .ClientEvents(events => events.OnRowSelected("onRowSelected")) 
        .RowAction(row => 
        { 
            row.Selected = row.DataItem.RoleName.Equals(Model.Role.RoleName); 
        }) 
         
%> 
<%} 
   else 
   { %> 
    <h2>Create a New Role</h2> 
    <%= Html.ValidationSummary("Role creation was unsuccessful. Please correct the errors and try again.") %> 
 
    <% using (Html.BeginForm()) { %> 
        <div> 
            <fieldset> 
                <legend>Role Information</legend> 
                <p> 
                    <label for="rolename">Role Name</label> 
                    <%= Html.TextBox("rolename") %> 
                    <%= Html.ValidationMessage("rolename") %> 
                </p>     
                <p> 
                    <button class="t-button t-state-default" type="submit">Add</button> 
                </p> 
                 
            </fieldset> 
        </div> 
    <% } %> 
 
   <%} %> 
 
<% if (Model.Role.RoleName !=null) 
   { %> 
<h2>Users In Role (<span id="RoleName"><%= Model.Role.RoleName %></span>)</h2> 
 
        <%= Html.Telerik().Grid((IEnumerable<PlatformUser>)Model.UsersInRole) 
                .Name("UsersInRole") 
                .ToolBar(commands => commands.Insert()) 
                .DataKeys(keys => keys.Add(c => c.UserName)) 
                .Columns(columns => 
                { 
                    columns.Bound(c => c.UserName).Width(130); 
                    columns.Command(commands => 
                    { 
                        commands.Edit(); 
                        commands.Delete(); 
                    }).Width(180).Title("Commands"); 
                }) 
                .DataBinding(dataBinding => 
                { 
                    dataBinding.Ajax() 
                    .Select("MaintainPlatformRoles", "PlatformAdministration", new { Role = Model.Role, ActionName = "Select" }) 
                    .Insert("MaintainPlatformRoles", "PlatformAdministration", new { Role = Model.Role, ActionName = "Insert" }) 
                    .Update("MaintainPlatformRoles", "PlatformAdministration", new { Role = Model.Role, ActionName = "Edit" }) 
                    .Delete("MaintainPlatformRoles", "PlatformAdministration", new { Role = Model.Role, ActionName = "Delete" }); 
                }) 
                .Pageable() 
                .Sortable() 
 
       %> 
         
<% }%> 

the first grid runs and when the toolbar insert button clicked, new line created and insert and cancel button showed inline of the new row, and while the insert button clicked the right action is fired. 
the problem is the second grid, while loading, the second grid just like not-ready, the refresh icon shows busy(don't know why, maybe the there's no user in the role so the binding data is empty?), and while click the toolbar insert button, the new row shows as desired but there's only one column, but not expected two column(the other is the command column containing command button), and the insert and cancel button shows at the end of the row, but it's not big issue, the bad thing is while click the insert button, the defined action is not fired, which suppose to invoke the method  
                    .Insert("MaintainPlatformRoles", "PlatformAdministration", new { Role = Model.Role, ActionName = "Insert" }) 
as defined. 
 
the snapshot is attached



Tags
Grid
Asked by
Jack Ma
Top achievements
Rank 1
Share this question
or