Hi,
Has anyone got an example where you can toggle rows in the grid from a button somewhere else on the page?
I am trying to get when the page is loaded to hide the orders that are complete but show these orders if the user clicks on a "Show Completed" button.
Thanks,
John
Hi John,
Thanks for using Syncfusion products.
Your requirement of Toggle filtering via button can be achieved by handling onclick Event in button.
Please refer to the below code snippet to achieve this.
[CSHTML]
function hideGridRow() {
var gridobj = $find("GenericListGrid");
var visibleRows = gridobj._gridContentTable.children[1].rows;
var colIndex = gridobj._MvcTable.get_columnIndexByName("valid");
for (i = 0; i < visibleRows.length; i++)
{
if (visibleRows[i].cells[colIndex + 1].children.valid.checked == false)
{
gridobj.hideRow(i);
}
}
}
function showGridRow() {
var gridobj = $find("GenericListGrid");
var visibleRows = gridobj._gridContentTable.children[1].rows;
for (i = 0; i < visibleRows.length; i++)
{
gridobj.showRow(i);
}
}
Please refer to the attached sample application for further reference.
Please get back to us if you need further assistance.
Regards,
Shanmugaraja K
Hi Shanmugaraja,
Thanks for getting back to me but is there a way to use the grid while the rows are hidden? For example the rows which are not valid still wouldn't show even if you loop through the pages or group items?
Trying to get the invalid rows to be hidden from the start and to be loaded soon as the user click "show invalid".
Thanks for your help,
John
Hi John,
Thanks for your update.
Your requirement of
Toggle filtering via button can be achieved by handling OnActionSuccess Event.
Please refer to the below code snippet to achieve this.
[CSHTML]
function Onsuccess(sender,args)
{
if ($("#btn1").is(':disabled')) {
if (args.RequestType == "paging" || args.RequestType == "sorting") {
var gridobj = $find("GenericListGrid");
var visibleRows = gridobj._gridContentTable.children[1].rows;
var colIndex = gridobj._MvcTable.get_columnIndexByName("valid");
for (i = 0; i < visibleRows.length; i++) {
if (visibleRows[i].cells[colIndex + 1].children.valid.checked == false) {
gridobj.hideRow(i);
}
}
}
}
else if ($("#btn2").is(':disabled'))
{
if (args.RequestType == "paging" || args.RequestType == "sorting") {
var gridobj = $find("GenericListGrid");
var visibleRows = gridobj._gridContentTable.children[1].rows;
for (i = 0; i < visibleRows.length; i++)
{
gridobj.showRow(i);
}
}
}
}
Please refer to the attached sample application for further reference.
Please get back to us if you need further assistance.
Regards,
Shanmugaraja KHi Shanmugaraja,
Thanks for that works great but how would you implement this for a hierarchical grid with where the parent has the active column?
Cheers mate,
John
Hi John,
Thanks for your update.
Your requirement of Toggle filtering via button for a hierarchical grid can be achieved by handling onclick Event in button.
Please refer to the below code snippet to achieve this.
[CSHTML]
function hideGridRow() {
var gridobj = $find("GenericListGrid");
var visibleRows = gridobj._gridContentTable.children[1].rows;
var colIndex = gridobj._MvcTable.get_columnIndexByName("valid");
for (i = 0; i < visibleRows.length; i++) {
if (visibleRows[i].className == "")
{
if (visibleRows[i].cells[colIndex + 2].children.valid.checked == false)
{
gridobj.hideRow(i);
if (visibleRows[i + 1].className == "GenericListGridChildRow")
{
$(visibleRows[i + 1]).hide()
}
}
}
$("#btn1").attr("disabled", "disabled");
$("#btn2").removeAttr("disabled", "disabled");
}
}
function showGridRow() {
var gridobj = $find("GenericListGrid");
var visibleRows = gridobj._gridContentTable.children[1].rows;
for (i = 0; i < visibleRows.length; i++)
{
gridobj.showRow(i);
}
$("#btn2").attr("disabled", "disabled");
$("#btn1").removeAttr("disabled", "disabled");
}
Please refer to the attached sample application for further reference.
Please get back to us if you need further assistance.
Regards,
Shanmugaraja K
Thanks Shanmugaraja sorted.
Hi John,
Thanks for your update.
we will wait to hear from you.
Please let us know if you need further assistance.
Regards,