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

Unwire gridcolsizinghelper

Hi, I am using this helper and it works great for wiring. However, I loop through many user added grids when I wire them and I would like to give the user the option to unwire select grids. However the unwire() method doesn't appear to have a built in way to pass a specific grid. Is there any way to accomplish this?

6 Replies

AA Arulraj A Syncfusion Team March 19, 2019 10:16 AM UTC

Hi Travis, 

Thanks for using Syncfusion product. 

By using separate GridColSizingHelper objects for each gridcontrol you can wire and unwire them respectively. As per the code when you use the same GridColSizingHelper object for all the gridcontrols while wiring the second gridcontrol, it will unwire the first gridcontrol which will not be the actual requirement. 

public void WireGrid(GridControlBase grid) 
{ 
       if(this.grid != null) 
              UnwireGrid(); 
       this.grid = grid; 
       grid.Model.Options.SmoothControlResize = false; 
       this.grid.Model.QueryColWidth += new GridRowColSizeEventHandler(Model_QueryColWidth); 
       this.grid.ResizingColumns += new GridResizingColumnsEventHandler(grid_ResizingColumns); 
       grid.Refresh(); 
       WireGridFlag = true; 
       return; 
} 
 
public void UnwireGrid() 
{ 
       if(this.grid != null) 
       { 
              this.grid.ResizingColumns -= new GridResizingColumnsEventHandler(grid_ResizingColumns); 
              this.grid.Model.QueryColWidth -= new GridRowColSizeEventHandler(Model_QueryColWidth); 
              this.grid.Refresh(); 
              this.reset(); 
              this.grid = null; 
       } 
} 

Let us know whether this helps also if you need any further assistance on this. 

Arulraj A 



TC Travis Chambers March 19, 2019 07:41 PM UTC

Thank you for your feedback! Even though I am wiring all grids to the same helper, wiring oje does not unwire another. They all maintain their wired nature, which is a good thing as most often than not they need to be resized proportionally. Sometimes, however they need to be manually sized.

Since the number of grids present changes dynamically I cannot give each one their own helper object unless I can then find and use each helper object from another button click.

Is there anyother way to unwire, or at least override the automatic resizing for the selected grid?


AA Arulraj A Syncfusion Team March 20, 2019 09:13 AM UTC

Hi Travis,  

Thanks for the update. 

You can unwire the events by adding a new method which can assign the passed grid as its member grid and call the UnWireGrid() method. This works as per your requirement. 

C# 
public void UnwireGrid(GridControlBase grid) 
{ 
       this.grid = grid; 
       UnwireGrid(); 
} 

private void button5_Click(object sender, EventArgs e) 
{ 
    Helper1.UnwireGrid(this.gridControl1); 
} 

Please let us know if you need any further details on this. 
  
Regards,  
Arulraj A 



TC Travis Chambers March 27, 2019 11:52 AM UTC

Thank you for your feedback. unfortunately, it still doesn't work. It does successfully pass the correct grid to the unwire event but it does not actually unwire it. I suspect this is just a side effect of wiring multiple grids at once. if you have any other suggestions to try I will greatly appreciate it. If not, then I may just try to find a workaround for it.

I do have another related question however. When a grid is wired, is there a good way to take into account hidden cols and rows when resizing? Right now there is extra white space where the hidden cols or rows would be and I need the grids to resize to fit only visible cols and rows with no extra space in the grid size.

Thanks!


MG Mohanraj Gunasekaran Syncfusion Team March 28, 2019 05:50 PM UTC

Hi Travis, 
 
Thanks for your update. 
 
We can understand your scenario. We need one more business day to achieve your reported scenario. So, we will check and update the details on tomorrow 29th March 2019. 
 
Regards, 
Mohanraj G 



DY Deivaselvan Y Syncfusion Team April 2, 2019 03:04 AM UTC

Hi Travis,

Kindly share your helper class along with the code example on how you are wire and unwire the grid using that helper. This will help us to resolve your issues in your implementation and provide solution at the earliest.

Regards,
Deivaselvan 


Loader.
Live Chat Icon For mobile
Up arrow icon