Adding checkbox and dropdown in Grid cell

Dec 18, 2013 at 5:14 AM
I would like to add checkbox and dropdown to each grid cell.
There will be one button outside the grid. On click of the button, i would like to populate checked and dropdown selected values from the grid.

Any help is really appreciated.
Coordinator
Dec 18, 2013 at 4:31 PM
Hi,

Render button, checkbox etc in the grid cell - https://gridmvc.codeplex.com/wikipage?title=Render%20button%2c%20checkbox%20etc%20in%20the%20grid%20cell&referringTitle=Documentation

You can apply to checkboxes some css class like:
columns.Add()
            .Encoded(false)
            .Sanitized(false)
            .SetWidth(30)
            .RenderValueAs(o => Html.CheckBox("checked", false, new {@class = "my-checkbox"}));
after that create additional script to select it (for example)
<script>
$(function(){
      $("#my-button").on("click", function(){
             $(".my-checkbox").attr("checked","checked");
      });
});
</script>
Dec 19, 2013 at 4:46 AM
Edited Dec 19, 2013 at 4:52 AM
Hi Bukharin,
Thanks for your response.

Along with checkbox, I have added dropdown in another column.

Drop down is also part for grid row.

columns.Add()
        .Encoded(false)
        .Sanitized(false)
        .SetWidth(30)
        .RenderValueAs(o => Html.CheckBox("checked", false, new {@class = "my-checkbox"}));
columns.Add()
        .Encoded(false)
        .Sanitized(false)
        .SetWidth(30)
__ __ .RenderValueAs(o => Html.DropDownList("checked", false, new {@class = "my-dropdwon"}));____

Note: Above lines i provided for reference. The DropDownList is loading from the modal class. The syntax could be wrong. I have put, for your reference.

Button is present outside the grid control.

When user click on button, I would like get the checked rows and its associated dropdown values,which user has selected for each row.

Any help is really appreciated.
Coordinator
Dec 23, 2013 at 2:07 AM
Hi,

Grid.mvc only creates a checkbox with specific css classes for you. You need to learn a jQuery api to create a custom functionallity - http://api.jquery.com/category/selectors/

I guess in your case you can use $('.my-checkbox:checked') selector.
Jan 28, 2014 at 10:52 PM
Hi, Youvraj, can solve your problem? can post what do yo do if you solve ? thankss!

Sorry for mi English