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

model.Options.DisplayEmptyColumns is letting me drag into invisible columns

Hi, I have a DataBoundGrid(1.6.1.5) with around 50 columns. They are hidden using gridModel.HideCols[nn] = true method. When I set model.Options.DisplayEmptyColumns to true, it is giving me a visual effect that I want. But, when I drag my last column to the right, it is letting me drop into the empty column. Somehow it is thinking those invisible columns are visible. Then my draged column becomes invisible and get lost. I tried handling grid.ColsMoving event handler. It is giving me e.From = 11 and e.Target = 37 when I am seeing only two columns. Can you please help me? thanks, - Reddy

3 Replies

AD Administrator Syncfusion Team September 16, 2003 02:19 AM

I think I was able to avoid the bad drop in the attached sample using a ColsMoving handler. But I do not know of a way of not showing the drop cursor past the good columns. If you just wanted to drop the column to the right of teh last column if the user tried to drop the col past the good columns, then I think you could cancel teh current drop in ColsMoving, and call MoveCols to position the column correctly. Here is sample code:
private void gridModel_ColsMoving(object sender, GridRangeMovingEventArgs e)
{
	Console.WriteLine("gridModel_ColsMoving " + e.Target.ToString());
	if(e.Target > this.gridDataBoundGrid1.Model.ColCount)
	{
		e.Cancel = true;
                this.gridDataBoundGrid1.Model.Cols.MoveRange(e.From, e.Count, this.gridDataBoundGrid1.Model.ColCount);
	}
}


AD Administrator Syncfusion Team September 16, 2003 09:59 AM

Clay, Your workaround has a problem. 1. Run your application. 2. Select Col0, Col1 and Col2. 3. Drag and Drop after last column (col 8). 4. Notice that now col0, col1 and col2 are missing. How can we fix this problem? FYI, Windows Explorer (view detail grid on right side) implements a nice feature where you can drop any column past the last column and it will simply move it to the last. This would be nice to have. thanks, - Reddy


AD Administrator Syncfusion Team September 16, 2003 03:57 PM

This seems to work...
private void gridModel_ColsMoving(object sender, GridRangeMovingEventArgs e)
{
	if(e.Target + e.Count - 1 > this.gridDataBoundGrid1.Model.ColCount )
	{
		e.Cancel = true;
	 this.gridDataBoundGrid1.Model.Cols.MoveRange(e.From, e.Count, this.gridDataBoundGrid1.Model.ColCount - e.Count + 1);
	}
}

Loader.
Live Chat Icon For mobile
Up arrow icon