Hide/Unhide Columns and Rows using GridWeb

Hello !


First, thank you for your great component, I am very happy using Aspose.Cells.GridWeb.

I have to developped Excel-like interface in a Web application and have a list of Excel features which need to be implemented in this Excel-like.

Most of them are natively in GridWeb so no problem. But I have an issue with hiding/unhiding columns and rows.
I red that the solution is to redefine height or width to 0. Ok fine.

But my question is : how can I do this dynamically ? This mean that the end-user have to be able to hide or unhide columns and rows by himself.
Is there some client-side event I can catch to do this ?

Thanks for your consideration.
Hi,

Yes, you can hide/unhide the column and rows in the worksheet programmatically, see the sample code.

Sample code:

WebWorksheet sheet = GridWeb1.WebWorksheets[0];
//Set the first column's width to 0 to hide it
sheet.Cells.SetColumnWidth(0, new Unit(0, UnitType.Point));

Similarly using SetColumnWidth() method you may unhide a column by specifying your desired width.

Thank you.

Well after some investigation i found that i can add some entries in the right-click menu.
So i have added an Hide entry and a Display entry like this :

<agw:GridWeb id=“GridWeb1” runat=“server” XhtmlMode=“true” Height=“600px” Width=“100%” NoScroll=“false” EnableClientColumnOperations=“true” EnableClientMergeOperations=“true” EnableClientResizeColumnRow=“true” EnableClientRowOperations=“true” EnableClientFreeze=“true” OnCustomCommand=“GridWeb1_CustomCommand” OnSaveCommand=“GridWeb1_SaveCommand”>

<agw:CustomCommandButton runat=“server” Command=“Hide” Text=“Hide” CommandType=“ContextMenuItem”></agw:CustomCommandButton>
<agw:CustomCommandButton runat=“server” Command=“Display” Text=“Display” CommandType=“ContextMenuItem”></agw:CustomCommandButton>

</agw:GridWeb>

And catch the event in code behind like this :

protected void GridWeb1_CustomCommand(object sender, string command)
{
switch (command)
{
case “Hide”:
if (GridWeb1.ActiveCell != null)
{
int row = GridWeb1.ActiveCell.Row;
WebCells cells = GridWeb1.WebWorksheets[GridWeb1.ActiveSheetIndex].Cells;
cells.SetRowHeight(row, new Unit(0, UnitType.Point));
}
break;

case “Display”:
if (GridWeb1.ActiveCell != null)
{
int row = GridWeb1.ActiveCell.Row;
WebCells cells = GridWeb1.WebWorksheets[GridWeb1.ActiveSheetIndex].Cells;
cells.SetRowHeight(row, new Unit(10, UnitType.Point));
}
break;
}
}

For information my control is instancied with the below code. The Excel file contains 2 sheets and some formulas (by the way i am not able to navigate between the sheet included the Evaluation Copyright Warning sheet).

protected void Page_Load(object sender, EventArgs e)
{
//if first visit this page clear GridWeb1
if (!IsPostBack)
{
GridWeb1.WebWorksheets.Clear();
string filename = “C:\Documents and Settings\xxxxx\My Documents\xxxx\Proto.xls”;
GridWeb1.WebWorksheets.ImportExcelFile(filename);
GridWeb1.WebWorksheets.RunAllFormulas();
GridWeb1.EnableAJAX = true;
}
GridWeb1.WebWorksheets.RunAllFormulas();
}

But it doesn’t work and i don’t understand why. I try to debug and when i’m clicking on “Hide” on the menu it doesn’t run the GridWeb1_CustomCommand method.

Still on this right-click menu, how make the default features work ? I try to use the “Freeze” functionnality available in the menu but it does nothing and doesn’t freeze the lines i had selected.

I am using Internet Explorer 7 and can’t change (official browser in the company i work for).

Thanks for taking consideration into my issues !

Well i don’t know if it’s because i’m using IE7 but i have many issues with the context menu which doesn’t work and it seems to be related to EnableAjax = “true”.

But all the modifications (calculation formulas, freezing, hiding, etc.) have to be done without refreshing the page.

Is there some way to do this ? Does all context menu features will work if i don’t use Ajax refreshing ?

Hi,


I think it should work fine including freeze panes feature. I have tested some features with latest version and it works fine with it. We highly recommend you to kindly check the demos for your reference:
http://www.aspose.com/community/files/51/.net-components/aspose.cells-for-.net/entry294646.aspx

Also, install and use latest version of the product which is v7.2.15.2000 (GridWeb).

If you still find the issue, kindly create a separate (runnable) sample project with v7.2.15.2000 (GridWeb), zip it and post it here to reproduce the issue on our end. We will check it soon.

Also, make sure that your project is using latest “acw_client” folder scripting files (of v7.2.15.2000), you may specify its path in web.config file for GridWeb accordingly.

Thank you.

Hi,

Thanks for your answer. I was absent that’s why i’m responding only today.

I have the last version of Aspose.Cells (including GridWeb).
I am trying to create a new blank project to do my tests and i will be back to you if i am still facing problems.

Hi,

Thanks for your posting.

Please feel free to post if you encounter any other issue, we will be glad to help you further.