Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
2732
IgGrid, Responsive: change column width with verticalRendering disabled
posted

Hello

We are trying to create a grid that is responsive. We are using the responsive feature for this and it kind of works. 
Except we want to change the width of a column when the grid enters responsive mode. 

We have following setup: http://jsfiddle.net/k3759o0c/13/ 

As you can see we have 4 columns:

  • ID: 25%, hidden on mobile
  • Name: 40%, shown on mobile
  • Title: 10%, shown on mobile
  • Phone: 25%, hidden on mobile

When changing into responsive mode these percentages are still in play, but the last visible column takes all available width (being Title here). So Title becomes larger than Name, while the opposite should be true.

Is there any way to solve this? Like changing the width of the columns when entering responsive mode?

Thank you!

Parents
  • 17590
    Verified Answer
    Offline posted

    Hello Michael,

    Thank you for posting in our community.

    What I can suggest for achieving your requirement is handling responsiveModeChanged event. In this event the width option of the columns can be set relative to the new responsive mode. For example:

    				responsiveModeChanged: function (evt, ui) {
    		     			if(ui.mode === "phone"){
    		    				ui.owner.grid.options.columns[1].width = "80%";
    		    				ui.owner.grid.options.columns[2].width = "20%";
    	    				}
    				}

    When column widths are set in % and the new responsive mode hides two of the columns the sum of the remaining column widths in % do not match 100%. In this scenario the browser is making its own calculations in order to get new column width. 

    In my snippet I am handling only the scenario when responsive mode is "phone", however, my suggestion is to handle all modes and set the appropriate widths to ensure that columns are going to be rendered as you expect.

    Please let me know if you need any further assistance regarding this matter.

Reply Children