In this demo multiple modes of grid selection are shown.
Multicheck select
Drag a column header and drop it here to group by that column
3675 Eve Pizza 45 Home 3671 Phil Apple 100 Tavern 3667 Richard Cheesecake 30 University 3663 Scott Shepherd's pie 30 Home 3659 Monica Banana 20 Home 3655 Sylvain Oat meal 45 Diner 3651 Trey Big Salad 79 University 3647 Megan Banana 18 Restaurant 3643 Leonard Pizza 39 Visit 3639 Gordon French toast 21 Home
selection:
description view
Select multiple rows by clicking on them, you can also use Ctrl and Shift to select/deselect multiple rows.
Adding class 'awe-nonselect' to the row will make the row non selectable. You can also add this class to a tag inside the row, so that when you click inside that the tag the selection won't occur.
GridDemo/Selection.cshtml
src
@(Html.Awe().Grid("MultiCheckSelectGrid") .Url(Url.Action("GetItems", "LunchGrid")) .Height(350) .Selectable() .Columns( new Column { Bind = "Id", Width = 75 }, new Column { Bind = "Person" }, new Column { Bind = "Food.Name" }, new Column { Bind = "Price", Width = 100 }, new Column { Bind = "Location" })) <br /> <div class="expl"> <span>selection:</span> <span id="selection" class="wwrap"></span> </div> <script> $(function () { $('#MultiCheckSelectGrid') .on('aweselect', function () { var selectedItems = $('#MultiCheckSelectGrid').data('api').getSelection(); $('#selection').html(JSON.stringify(selectedItems)); }) .on('aweload', function () { $('#selection').empty(); }); }); </script>
Single select
select one row by clicking on it
Drag a column header and drop it here to group by that column
3675 Eve Pizza 45 Home 3671 Phil Apple 100 Tavern 3667 Richard Cheesecake 30 University 3663 Scott Shepherd's pie 30 Home 3659 Monica Banana 20 Home 3655 Sylvain Oat meal 45 Diner 3651 Trey Big Salad 79 University 3647 Megan Banana 18 Restaurant 3643 Leonard Pizza 39 Visit 3639 Gordon French toast 21 Home
selection
show code
GridDemo/Selection.cshtml
src
@(Html.Awe().Grid("SingleSelectGrid") .Url(Url.Action("GetItems", "LunchGrid")) .Height(350) .Selectable(SelectionType.Single) .Columns( new Column { Bind = "Id", Width = 75 }, new Column { Bind = "Person" }, new Column { Bind = "Food.Name" }, new Column { Bind = "Price", Width = 100 }, new Column { Bind = "Location" })) <br /> <div> <span>selection</span> <span id="selection1" class="wwrap"></span> </div> <script> $(function () { $('#SingleSelectGrid') .on('aweselect', function () { var selectedItems = $('#SingleSelectGrid').data('api').getSelection(); $('#selection1').html(JSON.stringify(selectedItems)); }) .on('aweload', function () { $('#selection1').empty(); }); }); </script>
Multiselect
use click, ctrl+click, shift+click, ctrl+shift+click to select multiple rows
Drag a column header and drop it here to group by that column
3675 Eve Pizza 45 Home 3671 Phil Apple 100 Tavern 3667 Richard Cheesecake 30 University 3663 Scott Shepherd's pie 30 Home 3659 Monica Banana 20 Home 3655 Sylvain Oat meal 45 Diner 3651 Trey Big Salad 79 University 3647 Megan Banana 18 Restaurant 3643 Leonard Pizza 39 Visit 3639 Gordon French toast 21 Home
select all
deselect all
select where price > 50
selection
show code
GridDemo/Selection.cshtml
src
@(Html.Awe().Grid("MultiselectGrid") .CssClass("keynav") .Url(Url.Action("GetItems", "LunchGrid")) .Height(400) .Selectable(SelectionType.Multiple) .Columns( new Column { Bind = "Id", Width = 75 }, new Column { Bind = "Person"}, new Column { Bind = "Food.Name" }, new Column { Bind = "Price", Width = 100 }, new Column { Bind = "Location" })) <br /> <button id="btnSelectAll" class="awe-btn">select all</button> <button id="btnDeselectAll" class="awe-btn">deselect all</button> <button id="btnSelectByPrice" class="awe-btn">select where price > 50</button> <br /> <br /> <div> <span>selection</span> <span id="selection2" class="wwrap"></span> </div> <script> $(function () { $('#MultiselectGrid') .on('aweselect', function () { var selectedItems = $('#MultiselectGrid').data('api').getSelection(); $('#selection2').html(JSON.stringify(selectedItems)); }) .on('aweload', function () { $('#selection2').empty(); }); $('#btnSelectAll').click(function () { $('#MultiselectGrid .awe-row').addClass('awe-selected'); $('#MultiselectGrid').trigger('aweselect'); }); $('#btnDeselectAll').click(function () { $('#MultiselectGrid .awe-row').removeClass('awe-selected'); $('#MultiselectGrid').trigger('aweselect'); }); $('#btnSelectByPrice').click(function () { $('#MultiselectGrid .awe-row').removeClass('awe-selected').each(function (ix, item) { if (aweUtils.model($(item)).Price > 50) { $(item).addClass('awe-selected'); } }); $('#MultiselectGrid').trigger('aweselect'); }); }); </script>
Comments