mardi 26 mai 2015

Get closest link href element with the help of checkbox in jquery

I am using Telerik MVC Grid. In my first column there is a client template for checkbox and in very next column, there is client template for a href. On checkbox click, I need to enable/disable link in next column using jquery only for particular row. Here is grid

<% Html.Telerik().Grid<ViewModel>()
        .Name("NewGrid").HtmlAttributes(new { style = "width:99%;" })
        .CellAction(cell => { cell.HtmlAttributes["style"] = "font-family:Arial;font-size:11px;margin:0px;"; })
        .ToolBar(commands =>
                    {
    %>
    <% commands.Insert().ButtonType(GridButtonType.Text).HtmlAttributes(new { style = "color:black;" }); %>
    <% commands.Custom().Text("Save").Action("myAction", "myController").HtmlAttributes(new { style = "color:black;" }); %>
    <% commands.Custom().Text("Cancel").Action("myAction", "myController").HtmlAttributes(new { style = "color:black;" }); %>
    <%                      
                    })
         .DataKeys(key => key.Add("StringID").RouteKey("StringID"))
        .Columns(columns =>
       {
           columns.Command(commands =>
           {
               commands.Edit().ButtonType(GridButtonType.Image).HtmlAttributes(new { style = "min-width:12px; padding-right:2px;" });
               commands.Delete().ButtonType(GridButtonType.Image).HtmlAttributes(new { style = "min-width:12px; padding-right:2px;" });
           }).Width(75).Title("Commands");
           columns.Bound(c => c.col1).ClientTemplate("<input type='checkbox' id='col1' name='col1' onChange='return onChangecol1(this)'/>").Title("Select").Width(86);
           columns.Bound(c => c.StringID).ClientTemplate("<a href='#' title='col2' id='col2' onclick='return getdata(<#=StringID#>)'> Link</a>").Title("Action").Width(70);

       })
       .DataBinding(dataBinding => dataBinding.Ajax().Select("GetData", "myController")             
          )             
                  .Editable(editing => editing.Mode(GridEditMode.InLine))
        .Pageable(p => p.PageSize(50))

         .Scrollable((scroll) =>
         {
             scroll.Enabled(true).Height(355);
         })
        .Render();       
    %>

can you please help me?




Aucun commentaire:

Enregistrer un commentaire