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. Image for the cookie policy date

Hiding first column in the grid set''s the focus on Row header and causes problems



Hi,
I am using Syncfusion GDBG 4.402.0.51 version.

Here is the simple case.

I an binding my grid to the datasource which let's say has 4 columns.
Once the grid is bound, I am hiding the very first column which in my case happens to be a autogenerated primary key column which I don't need to show users.

Problem:
When the grid is displayed the focus is on the row header column.
I use down/Up arrow keys and the focus doesn't show but it is actually on the hidden column.
If I start typing it changes the content of that hidden column. This is a bug. If the column is hidden, focus should never go on that column.
It causes all sorts of problems.

Thanks,
Pratima

4 Replies

RA Rajagopal Syncfusion Team August 24, 2007 02:00 AM UTC

Hi Pratima,

Thanks for your interest in Syncfusion Products.

By default, when the grid is loaded the currentcell will be set to the cell(1, 1). In your case, the current cell will be set to the hidden column when grid is loaded. Before the grid is displayed, you could determine the first visible column index in grid and move the currentcell to it. Below is some code snippets.

// move the currentcell to the first visiblecolumn in grid
int firstVisibleCol = GetFirstVisibleColIndex(this.gridDataBoundGrid1);
this.gridDataBoundGrid1.CurrentCell.MoveTo(1, firstVisibleCol);

private int GetFirstVisibleColIndex(GridDataBoundGrid grid)
{
int firstVisibleCol = -1;
for (int i = 1; i < grid.Model.ColCount; i++)
{
if (!grid.Model.HideCols[i])
{
firstVisibleCol = i;
break;
}
}
return firstVisibleCol;
}

Once you have set the currentcell to the visible column in grid, then you will not be able to focus the hidden column using arrowkeys/mouse, unless you explicitly call the Currentcell.MoveTo method to move the currentcell to the hidden column.

Please refer the below sample for more information on this regard.
http://websamples.syncfusion.com/samples/Grid.Windows/F67572/main.htm

Let me know if you have any other questions.

Have a nice time.
Regards,
Rajagopal



PR Pratima August 24, 2007 10:01 PM UTC

Thanks for your response and I already knew what to do to workaround this "defect".

I would have never posted this message if the problem was limited to only when the grid is displayed first time.

Problem is, Every time I click on the row header, focus goes back to the hidden cell.

I think it's ridiculous for clients of the grid to have to force the focus manually each time the row header is clicked.

If the columns are hidden GDBG should NOT be setting the focus on the cell of the hidden column in the first place.



>Hi Pratima,

Thanks for your interest in Syncfusion Products.

By default, when the grid is loaded the currentcell will be set to the cell(1, 1). In your case, the current cell will be set to the hidden column when grid is loaded. Before the grid is displayed, you could determine the first visible column index in grid and move the currentcell to it. Below is some code snippets.

// move the currentcell to the first visiblecolumn in grid
int firstVisibleCol = GetFirstVisibleColIndex(this.gridDataBoundGrid1);
this.gridDataBoundGrid1.CurrentCell.MoveTo(1, firstVisibleCol);

private int GetFirstVisibleColIndex(GridDataBoundGrid grid)
{
int firstVisibleCol = -1;
for (int i = 1; i < grid.Model.ColCount; i++)
{
if (!grid.Model.HideCols[i])
{
firstVisibleCol = i;
break;
}
}
return firstVisibleCol;
}

Once you have set the currentcell to the visible column in grid, then you will not be able to focus the hidden column using arrowkeys/mouse, unless you explicitly call the Currentcell.MoveTo method to move the currentcell to the hidden column.

Please refer the below sample for more information on this regard.
http://websamples.syncfusion.com/samples/Grid.Windows/F67572/main.htm

Let me know if you have any other questions.

Have a nice time.
Regards,
Rajagopal




RA Rajagopal Syncfusion Team August 29, 2007 10:22 PM UTC

Hi Pratima,

Thanks for your patience.

This issue seems to a defect. Please open a direc-trac incident mentioning this forum id in the incident details. We will consult with the development team on this and let you know the details in the the direc-trac incident.

Regards,
Rajagopal


PR Pratima August 31, 2007 08:12 PM UTC

Hi RajGopal,
As suggested, I have entered a Direct Track incident # 37043 .
Thanks,
Pratima

>Thanks for your response and I already knew what to do to workaround this "defect".

I would have never posted this message if the problem was limited to only when the grid is displayed first time.

Problem is, Every time I click on the row header, focus goes back to the hidden cell.

I think it's ridiculous for clients of the grid to have to force the focus manually each time the row header is clicked.

If the columns are hidden GDBG should NOT be setting the focus on the cell of the hidden column in the first place.



>Hi Pratima,

Thanks for your interest in Syncfusion Products.

By default, when the grid is loaded the currentcell will be set to the cell(1, 1). In your case, the current cell will be set to the hidden column when grid is loaded. Before the grid is displayed, you could determine the first visible column index in grid and move the currentcell to it. Below is some code snippets.

// move the currentcell to the first visiblecolumn in grid
int firstVisibleCol = GetFirstVisibleColIndex(this.gridDataBoundGrid1);
this.gridDataBoundGrid1.CurrentCell.MoveTo(1, firstVisibleCol);

private int GetFirstVisibleColIndex(GridDataBoundGrid grid)
{
int firstVisibleCol = -1;
for (int i = 1; i < grid.Model.ColCount; i++)
{
if (!grid.Model.HideCols[i])
{
firstVisibleCol = i;
break;
}
}
return firstVisibleCol;
}

Once you have set the currentcell to the visible column in grid, then you will not be able to focus the hidden column using arrowkeys/mouse, unless you explicitly call the Currentcell.MoveTo method to move the currentcell to the hidden column.

Please refer the below sample for more information on this regard.
http://websamples.syncfusion.com/samples/Grid.Windows/F67572/main.htm

Let me know if you have any other questions.

Have a nice time.
Regards,
Rajagopal




Loader.
Live Chat Icon For mobile
Up arrow icon