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

Disable export buttons in rad grid

3 Answers 249 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Akki
Top achievements
Rank 1
Akki asked on 04 Jul 2012, 01:38 PM
Hi,

I have rad grid in my application. In that I have export buttons (export to pdf / word / excel). My issue is how to disable the button if there is no data inside the grid. Now, if there is no data in grid, if click on the export buttons empty file is creating. To avoid this, I need to disable export buttons if there is no data in grid. Thanks in Advance.

Regards,
Akki

3 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 04 Jul 2012, 04:14 PM
Hello,

protected void dgPassanger_PreRender(object sender, EventArgs e)
    {
        if (dgPassanger.MasterTableView.Items.Count == 0)
        {
            dgPassanger.MasterTableView.CommandItemSettings.ShowExportToExcelButton = false;
            dgPassanger.Rebind();
        }
    }


Thanks,
Jayesh Goyani
0
Akki
Top achievements
Rank 1
answered on 05 Jul 2012, 07:07 AM
Hello Jayesh,

Thanks for the reply. Is there any way for disabling the export buttons, rather than made it invisible.

Thanks,
Akki
0
Accepted
Jayesh Goyani
Top achievements
Rank 2
answered on 05 Jul 2012, 05:52 PM
Hello,

protected void dgPassanger_ItemCommand(object sender, GridCommandEventArgs e)
        {
            if (e.CommandName == RadGrid.ExportToExcelCommandName)
            {
                if (dgPassanger.MasterTableView.Items.Count == 0)
                    e.Canceled = true;
            }
        }


Thanks,
Jayesh Goyani
Tags
Grid
Asked by
Akki
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Akki
Top achievements
Rank 1
Share this question
or