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

How to set column width when orientation mode is changed ?

Hi, I'm Raphael and I have a question...

I'm using the sfDataGrid in a Xamarin iOS Unified project.

I have a situation that I'm doing a simple datagrid, with just two columns: "Name" and "Total".

What I need and I can´t do it until now:

I need to "increase" just the first width of the column "Name" when the iPhone is in landscape mode, and the "Total" column need to be in your automatic max recommended width value (this is already done automatically). 

I need to do this for the datagrid have an "auto layout" behavior, so the first column will increase it's width.

How can I do this?

I think that I have to manipulate just the first width of this one column, plus I have to calculate this width comparing the "Total" column width plus the screen width.

Is this possible? How can I do this?

The two images are attached in a zip file with what I need to do, can you help me?

Thanks

Attachment: sfdatagrid_question_2b617883.zip

16 Replies

DD Dharmendar Dhanasekar Syncfusion Team September 24, 2015 01:04 PM UTC

Hi Raphael,


Thank you for using Syncfusion Products. 


Currently there is no support for “auto layout”. However we have already considered this as a feature and it will be available in our volume 3 SP1 release. We appreciate your patience until then. For now, as a workaround you can achieve your requirement from the sample by manually setting the width of the Columns when the orientation changes. 


For your reference, we have prepared a sample based on this in which we have two columns. First column having the width of 3/4th of the frame and the second column having the width of 1/4th of the frame. When the orientation changes we had reapplied the column width in the ViewDidLayoutSubViews override. You can download the sample from the below location. 

 http://www.syncfusion.com/downloads/support/forum/120531/ze/Sample1293237356
Regards,
Dharmendar



SA SAGE September 24, 2015 01:37 PM UTC

Ok, thank you very much


SA SAGE September 24, 2015 03:16 PM UTC

Hi again.

So... I've implemented, but I'm still with some problems..

The width idea is great !

But I'm having some issues...

I'm working with a UIViewControler inside a "TabBarController"

First, I painted the sfGrid background in blue, so I can see if the Frame size is correct when the phone is landscaped

First issue:
Well, the Frame is working perfectly, but the columns are not "expanding" to the sfGrid frame size.

Second issue:
When in landscape mode, the vertical scrolling is not working... the componente "exceeds" the screen

The images are attached, with the code as well.

Can you please, help me? What an I doing wrong?

Thanks

Attachment: issues_9342a515.zip


DD Dharmendar Dhanasekar Syncfusion Team September 25, 2015 10:10 AM UTC

Hi Raphael,

We have analyzed your query with UIViewControler inside a "TabBarController" and we are able to reproduce the issue “columns are not expanding to the sfGrid frame size”. We have already fixed this issue and this fix will be available in upcoming release which is scheduled to be released by the end of this month. However we are not able to reproduce the issue “vertical scrolling not working in landscape mode”. It is working fine from our side. We have prepared a sample meeting your requirements with our latest dlls and you can download the same from the below location: 

Sample link: http://www.syncfusion.com/downloads/support/forum/120531/ze/Sample-1334401496 

Regards,
Dharmendar



SA SAGE September 25, 2015 12:18 PM UTC

Hi again!

Thank you very much for the answers! Very nice!

About the sample.. I noticed that you did two tabs. The first one, more simple.. and is working correctly.
The second one, is something like my case, with my .cs file modified.

Well... the first tab is ok! Perfect.
But the second.. I did, in this order:

1) Clicked in the "Tab2" (I noticed that the columns are not adjusted to the grid, ok, and the cells are still with white color, without the custom theme).

2) I rotate the simulator (Hardware > Rotate Right) [landscape mode], and the cells had assumed the custom theme now, perfect (I think that is just an adjust for the custom theme assume since the begin). And the scrolling is working perfectly

3) I change back to "portait" mode, going to "Hardware > Rotate Left". The custom cells are still there, the columns adjust perfectly, but... the scrolling is not working.
I'm using a iPhone 6s / iOS 9.0 emulator.

How can I fix this?

Thank you very much again


SA SAGE September 25, 2015 05:57 PM UTC

And I'm using the latest Syncfusion Xamarin 13.2.0.39.

In the example that you did, it was on Syncfusion Xamarin 13.2.0.29...


DD Dharmendar Dhanasekar Syncfusion Team September 28, 2015 11:34 AM UTC

Hi Raphael,
We have analyzed your query and we are able to reproduce the “Custom theme not applied on moving to second tab” issue. We have fixed it internally and the fix will be available in our upcoming main release Volume 3 scheduled to be rolled out by the end of September 2015. As of now you can avoid this issue by applying the custom theme in the GridViewCreated event. 

Regarding the “scrolling not working” issue, we are unable to reproduce the issue and it is working fine from our side. Since we had generated only 20 items in the sample last provided and the row height is less than the default row height value in the tab2, it might have looked like the grid is not scrolling as there were no more rows to scroll in portrait mode. We have modified the sample with the latest dlls (which includes column not expanding fix) to generate more data and to apply the custom theme in GridViewCreated event for your reference and you can download the sample from the below link.

Sample link: http://www.syncfusion.com/downloads/support/forum/120531/ze/Sample-1672756835 

Please let us know if you have any query.

Regards,
Dharmendar



SA SAGE September 28, 2015 12:36 PM UTC

Hi, good morning,

First, thanks! Now the style is working fine, and the columns were resized very well too.

But... the scrolling issue not worked.

If helps, in my case, I have a TabBarController, and how I have two tabs, each one is a ViewController, and just in one of them I will use the sfDataGrid.

Well, but this ViewController that will host the sfDataGrid, I have a default view that the system creates, and I created a second view inside the default view, called "DataGridSaldoBancarioUIView". The sfDataGrid will be inside this "DataGridSaldoBancarioUIView".

This "DataGridSaldoBancarioUIView" have a custom size. It's not "fill to parent". It's like a smaller view inside the default view.

I checked and the size of this second view that hosts the sfDataGrid is correct, and in the ViewDidLayoutSubviews event I'm coding something like 

    this.sfGrid.Frame = new CGRect(0, 0, TargetView.Frame.Width, TargetView.Frame.Height);

But, the sfDataGrid is not assuming this "frame size" at all. It's just assuming the width... but not the heigth. It's like the sfDataGrid ever pass the "limit" at the bottom.

What am I doing wrong?

I put an attached file with the print screens.

Can you please help me? Thanks


Attachment: sfDataGrid_Issue_e2a4bdf6.zip


DD Dharmendar Dhanasekar Syncfusion Team September 29, 2015 09:32 AM UTC

Hi Raphael,

Thank you for your response.

We have analyzed your query and tried to host the SfDataGrid as per your requirements and scrolling is working fine from our side. We got the grid scrolling and fit within the frame set for it. We tried the following method: inside a TabBarController we inserted two tabs each having a ViewController and hosted the grid in the second tab. As you mentioned we have created a view called “DataGridSaldoBancarioUIView” and added it as a subview of the second tab ViewController’s default view with a custom size. SfDataGrid is hosted within this view and it works fine with the frame it is arranged with. However we noticed an issue from our side. When scrolling, the last row of the Grid is not clipped if it extends the grid’s bottom frame and hence it might have looked like the grid is not fitting within its frame. We have fixed the issue internally and it will be included in our upcoming main release scheduled to be released by the end of September, 2015. 


We have prepared a sample based on your requirements with the custom dlls (which includes the fix for bottom clipping). We have also attached the screenshot of the issue that we faced and the screenshot of the correctly working grid for your reference.


You can download the sample and the screenshots from the below location:

Download link:http://www.syncfusion.com/downloads/support/forum/120153/ze/ScreenShots__and_Sample1726072537


For better understanding, we have modified the background color of the Default View inside the second tab ViewController to “Red”  and the background color of the “DataGridSaldoBancarioUIView” to “Green”and hosted the SfDataGrid inside it with a custom size. Incase if this does not fix  your problem, please revert us with the modified sample based on your application requirement with clear replication procedure.

Please let us know if you have any query.

Regards,
Dharmendar



SA SAGE September 29, 2015 01:53 PM UTC

Hi again!

Thank you very much for the issue correction, about the "clipped if it extends the grid’s bottom frame".

However, about my case... in the solution that you send, works perfectly.

But, applying in my real solution, don't.

But, I think I figured out where is the problem.

Continuing the case in my last answer, the unique difference is that in my case the "DataGridSaldoBancarioUIView" view is with auto-layout constraints.

For my surprise, if I delete this constraints, it works! (but the "DataGridSaldoBancarioUIView" is not with the correct size).

If I put back the auto-layout constraint in this sub-view, the issue back to happen.

But, the strange is that the DataGridSaldoBancarioUIView is with with correct size, it's not overtaking  the UIView parent when in auto-layout.

I'm sending some images and the .cs file. The red background is the DataGridSaldoBancarioUIView's background.  The cyan background it's just another view, that I'm not using now.

For last, other difference is that I'm using I'm using a storyboard, not a xib, and I don't create the DataGridSaldoBancarioUIView in execution time, it's in the storyboard designer.

Can you please help me?

Thank you very much.

Attachment: sfDataGrid_images_and_cs_file_dba35596.zip


DD Dharmendar Dhanasekar Syncfusion Team September 30, 2015 05:29 PM UTC

Hi Raphael,
Thank you for your response.
We have analyzed your query. In the screenshot that you have sent please note that there is warning at the right corner for the height constraint which is the reason for this issue. If you click the update constraints button there then the constraint will be set correctly and the grid will load within the view. I have attached some screen regarding these view constraints for your reference.
However if you have not set this height constraint for the purpose of orientation changes, then there will be height changes in the layout passes because of it and we are able to reproduce the issue in our side in such case. We have fixed it internally and this fix will be available in Volume 3 SP1 release which is scheduled to release by the end of October. As for now you can avoid this issue by skipping the first layout pass for the grid. You need to layout the grid only after the constraint is set for the internal view from the Storyboard. We have prepared a sample based on this work around and we have used a Boolean flag “skip” to skip the first layout pass for the grid and you can download the sample and the screenshots from the below location.
Sample link : http://www.syncfusion.com/downloads/support/forum/120531/ze/Samples_and_ScreenShots-646496901  
Please let us know if you have any query.
Regards,
Dharmendar


SA SAGE October 1, 2015 12:43 PM UTC

Hi!

About the warning at the right corner for the height constraint, I've not set this height constraint for the purpose of orientation changes, it's correct.


I'm happy to tell that now it works ! 
I've implemented the "skip" variable/control and it works very well now!

I'll use this way until the release that is comming.

Thank you very much








HN Harikrishnan N Syncfusion Team October 2, 2015 04:46 AM UTC

Hi Raphael,

As promised, the fix for the reported issue will be available in the Volume 3 SP1 release which is scheduled to be released by the end of October.

Regards,
Harikrishnan



HN Harikrishnan N Syncfusion Team October 5, 2015 07:00 AM UTC

Hi Raphael,

We are glad to announce that our Essential Studio Volume 3, 2015 is rolled out which includes the fix for the reported issues “Grid does not resize on rotation” and “GridStyle not applied when applying before the grid load”. It is available for download under the following link.

https://www.syncfusion.com/forums/120659/essential-studio-2015-volume-3-final-release-v13-3-0-7-is-available-for-download 

We thank you for your support and appreciate your patience in waiting for this release. Please get in touch with us if you would require any further assistance.

Regards,
Harikrishnan


SA SAGE October 5, 2015 01:45 PM UTC

Hi!

Ok, thank you very much. 

Now I'll wait for the SP1, that will correct the "skip variable implementation" for the storyboard issue.

Thanks, have a good week!


HN Harikrishnan N Syncfusion Team October 6, 2015 12:13 PM UTC

Hi Raphael,

Thank you for your update.

As promised, the fix for the reported issue will be available in the Volume 3 SP1 release which is scheduled to be released by the end of October.

Regards,
Harikrishnan


Loader.
Up arrow icon