⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Adjust grid headers width on Flexigrid



Ador El

Ador El
  • profile picture
  • Member

Posted 25 June 2013 - 06:15 AM

Is there any way to match the width of each column on flexigrid? 

There is a stackoverflow question about it, but I can not figure it out how to apply some fixes to flexigrid as grocery crud uses different js file structure.

 

Could you please help to adjust the column width for all cells on flexigrid on grocerycrud?

 

One solution says:

 

I had this problem as well. Here is my fix, and it works great. In flexigrid.js around line 678, change this line.

$(tdDiv).css({textAlign:pth.align,width: $('div:first',pth)[0].style.width});

to this

$(tdDiv).css({textAlign:pth.align,width: $('div:first',pth).width() + "px"});

but I can´t find it.

 

Thanks.

 


Robert

Robert
  • profile picture
  • Member

Posted 25 June 2013 - 07:05 AM

Hi, if i understand you correct look in the CSS ( flexigrid.css ) for 

 

.flexigrid div.form-div input[type=text], .flexigrid div.form-div input[type=password]

 

under you will find width: XXX px; modify the xxx to your value.

 

 

 


Ador El

Ador El
  • profile picture
  • Member

Posted 25 June 2013 - 16:24 PM

Hi Robert, I have tried it but had no luck, the only solution I have come is to use display as

->display_as('date_exam_tbl_a' ,'Date_of_Exam')...

If I use '_' then I have the columns displayed correctly, the problem comes when I do not have '_' words are overlaped


Robert

Robert
  • profile picture
  • Member

Posted 26 June 2013 - 06:36 AM

wait i understand wrong can you post a picture of you need exacly ? so i know, the css was for somthing diffrent.


Ador El

Ador El
  • profile picture
  • Member

Posted 26 June 2013 - 08:31 AM

Well, suppose I have some large tiltes, Flexigrid will overlap words when the table happens to have several columns

 

On stackoverflow there is a question http://stackoverflow.com/questions/1180166/consistent-grid-headers-with-flexigrid

 

, one solution is to do:

$("#yourtable th").each(function() {
   $(this).attr("width", $(this).width());
});

But I do not know how to define that on grocerycrud


Amit Shah

Amit Shah
  • profile picture
  • Member

Posted 26 June 2013 - 11:08 AM

Well what you can do is .. make a call to a function in grocery crud

 

$crud->set_js(base_url() . "assets/scripts/custom.js");

 

just make sure that in this file u don't use jquery ready .. but

window.onload = function() {
	$("#yourtable th").each(function() {
		$(this).attr("width", $(this).width());
	}); 
});

why.... because this will be added prior to jquery being loaded. And hence jquery ready function will fail. This will work through for sure...