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

[Solved] help please

2 Answers 68 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Keshia
Top achievements
Rank 1
Keshia asked on 21 Feb 2012, 05:30 PM
I have a telerik grid that renders a partial view which is shown below:
div class="editUserRoles <%=(Model._BesLogicProfile.Disabled) ? "disable" : string.Empty %>"><br><%<br>    //using (Ajax.AjaxForm("SaveRoles", "Administration", FormMethod.Post, new{@class="form" }, Model.UserName))<br>   using (Ajax.AjaxForm("SaveRoles", "Administration", FormMethod.Post,  Model.UserName))<br>    {%><br>        <%= Html.Hidden("UserName", Model.UserName) %><br>        <fieldset title="<%= AdministrationRes.ModifyRoles %>"><br>            <legend><%= AdministrationRes.ModifyRoles %></legend> <br>            <div class="checkboxlist"><br>                <%= Html.CheckBoxList("UserRoles", Model.AllRoles.ToListItems(r=>r,r=>Html.Resource("Roles_" + r.Name, SharedRes.ResourceManager),r=>Model.SelectedRoles.Contains(r)))%> <br>             </div><br>        </fieldset><br>        <div style="clear: left; text-align: center; margin-bottom: 1em;"><br>            <button type="submit" onclick="saveData()"> <br>                    <span><span><%= SharedRes.Save %></span></span><br>                </button><br>            <button type="reset" onclick="this.form.reset()"><br>                    <span><span><%= SharedRes.Cancel %></span></span><br>                </button><br>            <%if (Model._BesLogicProfile.Disabled)<br>              {%><br>            <button type="button" onclick="disableUser('<%=Model.UserName%>');"><br>                    <span><span><%=AdministrationRes.Disable%></span></span><br>                </button><br>            <%<br>                }<br>              else<br>{%><br> <button type="button" onclick="enableUser('<%=Model.UserName%>');"><br>                    <span><span><%=AdministrationRes.Enable%></span></span><br>                </button><br><%<br>}%><br><br><br>        </div><br><%  }%><br>    <br> <%= Ajax.AjaxFeedback(Model.UserName) %><br> <br></div><br><div><br></div>

So when the page is output, if I click on a checkbox, I would like it to save the value of the check . But when I click on my save button, I get carried to another page where I see the json result : "message: saved successfully...".
However, I don't want it to show this message on the client side. All I want is for the value of the checkbox to be saved and to stay on the section of the grid where I am. 
Is there a way to do this? I'm kind of new to telerik and ajax. 

2 Answers, 1 is accepted

Sort by
0
Dadv
Top achievements
Rank 1
answered on 22 Feb 2012, 04:37 PM
Hi,

try this :

<script type="text/javascript">
     function Test(c) {
 
         var request = $.ajax({
             url: '<%= Url.Action("ActionName", "ControllerName") %>',
             type: "POST",
             data: { OrderId: c.val() }
         });
 
         request.done(function (msg) {
             alert("ok");
         });
 
         request.fail(function (jqXHR, textStatus) {
                        c.attr('checked', !c.is(':checked'));
 
             alert("ko");
         });
      
         
     }
  
 </script>



in the grid :

columns.Template(o =>
            {
                %><input name="checkedRecords" type="checkbox" value="<%= o.OrderID %>" title="checkedRecords" onclick="Test($(this))"
                    <% if (checkedRecords.Contains(o.OrderID)) {
                         
                        %> checked="checked" <%
                      } %>
                   />
                <%
            }).Title("").Width(36).HtmlAttributes(new { style = "text-align:center" });


Regards,
0
Keshia
Top achievements
Rank 1
answered on 14 Mar 2012, 04:05 PM
thank you for the help
Tags
General Discussions
Asked by
Keshia
Top achievements
Rank 1
Answers by
Dadv
Top achievements
Rank 1
Keshia
Top achievements
Rank 1
Share this question
or