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

How to add editable checkbox in RadGrid MVC Razor

2 Answers 55 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.
Deepak
Top achievements
Rank 1
Deepak asked on 15 Sep 2011, 10:52 AM

Hi,
I am new in MVC razor and facing below problem
I have used radgrid on my view as given below and binded it with my Model . there is a column Publish which is bool type and returns true/false value, currenty this column displays as checkbox in disable form so I am not able to check/uncheck this checkbox. I want to dispaly this column as editable checkbox and on check/uncheck this checkbox need to call an Action.

I have already tried to convert it into TemplateColumn but I did not get expected result.

@{Html.Telerik().Grid<Sampling>(Model)
            .Name("TaskList")
            .DataKeys(keys => keys.Add(k => k.SamplingId))
            .HtmlAttributes(new { @Style = "width : float; height : float;"})
            .HtmlAttributes(new { @Style = "align:center; font-size:12px;" })
            .Columns(columns =>
                {
                    columns.Bound(o => o.SamplingName).Width(45).Title("Sampling Name (Id)");
                    columns.Bound(o => o.Category).Width(110).Title("Category (Id)");
                    columns.Bound(o => o.CDMAttribute).Width(75).Title("CDM Attribute (Id)");
                    columns.Bound(o => o.SampleSize).Width(29);
                    columns.Bound(o => o.AttributeSource).Width(42).Title("Sampling Source");
                    columns.Bound(o => o.IncludeChildCategories).Width(38).Title("Included Child");
                    columns.Bound(o => o.SamplingStatus).Width(30).Title("Status");
                    columns.Bound(o => o.TargetPrecision).Width(20).Format("{0:N}").Title("TP (%)");
                    columns.Bound(o => o.ActualPrecision).Width(20).Format("{0:N}").Title("AP (%)");
                    columns.Bound(o => o.DateCreated).Width(30).Title("Created on").Format("{0:MM/dd/yyyy}");          
                    columns.Bound(o => o.Publish).Width(25);
                })
              .DataBinding(dataBinding =>
              {
                  dataBinding.Ajax().Select("Index", "SamplingManager")
                  .Enabled(true);
                  dataBinding.Server().Select("Index", "SamplingManager", new { ajax = ViewData["ajax"] });
              }
              )
              .Pageable(page => page.PageSize(10).Style(GridPagerStyles.NextPreviousAndNumeric).Position(GridPagerPosition.Bottom))
              .Sortable()
              .Footer(true)
              .Scrollable(scroll => scroll.Enabled(true))
              .NoRecordsTemplate("No records to display")
              .Render();
                
}

2 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 15 Sep 2011, 01:14 PM
Hi Deepak,

I am afraid that the built-in editing functionality does not support the described behavior. The Grid must enter edit mode before you can change the checkboxes state.

It is possible to have editable checkboxes on initial load, however, it will be entirely up to you to track and handle (save) their state. For example

http://demos.telerik.com/aspnet-mvc/razor/grid/checkboxesserverside

http://demos.telerik.com/aspnet-mvc/razor/grid/headerfootertemplates

Best wishes,
Dimo
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
CI
Top achievements
Rank 1
answered on 02 Oct 2012, 03:36 PM
It is not so easy to preserve state of checkboxes when it goes with "automathic" ajax and grid  paging. I have fighted a night with it and came up with a working solution you might improve. I posted it here (answer that starts with "to preserve checked /unchecked checkbox state using telerik grid clientemplate across postbacks and async postbacks") :
Stack OverFlow how to preserve checkboxes state
Tags
Grid
Asked by
Deepak
Top achievements
Rank 1
Answers by
Dimo
Telerik team
CI
Top achievements
Rank 1
Share this question
or