We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Toggle filter via button

Thread ID:

Created:

Updated:

Platform:

Replies:

114222 Nov 6,2013 05:51 PM UTC Dec 12,2013 11:54 AM UTC ASP.NET MVC (Classic) 7
loading
Tags: Grid
John Ashton
Asked On November 6, 2013 05:51 PM UTC

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


Shanmugaraja K [Syncfusion]
Replied On November 8, 2013 09:58 AM UTC

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



sample_51aac5dc.zip

John Ashton
Replied On November 14, 2013 02:56 PM UTC

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


Shanmugaraja K [Syncfusion]
Replied On November 18, 2013 10:56 AM UTC

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 K

showhiderows_9c3d12e.zip

John Ashton
Replied On November 28, 2013 09:01 AM UTC

Hi 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


Shanmugaraja K [Syncfusion]
Replied On December 3, 2013 08:48 AM UTC

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



showhide_977e261b.zip

John Ashton
Replied On December 11, 2013 04:31 PM UTC

Thanks Shanmugaraja sorted.


Shanmugaraja K [Syncfusion]
Replied On December 12, 2013 11:54 AM UTC

Hi John,

 

Thanks for your update.

 

we will wait to hear from you.

 

Please let us know if you need further assistance.

 

Regards,

Shanmugaraja K

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;