Skip to main content
Edited from GANNT to GANTT
Source Link
Benny Skogberg
  • 25.5k
  • 12
  • 68
  • 163

Set the column width in GANNTGANTT view

When the GANNTGANTT view is being used, how could one resize the columns using jQuery without using the generated controlid (like in this example)? I'm looking for a way to do this in a re-usable javascript function.

I'm thinking to be able to find a control that has ListViewWebPartJSGrid in its id. It is possible that there would be more than one on the page, but that would work out.

[update]

Okay, I figured out how to fetch the control id (you can see the color change):

var $trackingGridID = $("[id$=_ListViewWebPartJSGrid_leftpane_mainTable]").attr("id");
$('#' + trackingGridID).css("background-color", "blue");

//this will fetch:  ctl00_ctl21_g_c3e5fead_d466_4448_9648_dcb92778921d_ListViewWebPartJSGrid_leftpane_mainTable

Now that I have the ID, it is a matter of figuring out how to modify the column widths...

But I want to do something like this:

function SetColumnWidths(column1, column2, column3)...

Set the column width in GANNT view

When the GANNT view is being used, how could one resize the columns using jQuery without using the generated controlid (like in this example)? I'm looking for a way to do this in a re-usable javascript function.

I'm thinking to be able to find a control that has ListViewWebPartJSGrid in its id. It is possible that there would be more than one on the page, but that would work out.

[update]

Okay, I figured out how to fetch the control id (you can see the color change):

var $trackingGridID = $("[id$=_ListViewWebPartJSGrid_leftpane_mainTable]").attr("id");
$('#' + trackingGridID).css("background-color", "blue");

//this will fetch:  ctl00_ctl21_g_c3e5fead_d466_4448_9648_dcb92778921d_ListViewWebPartJSGrid_leftpane_mainTable

Now that I have the ID, it is a matter of figuring out how to modify the column widths...

But I want to do something like this:

function SetColumnWidths(column1, column2, column3)...

Set the column width in GANTT view

When the GANTT view is being used, how could one resize the columns using jQuery without using the generated controlid (like in this example)? I'm looking for a way to do this in a re-usable javascript function.

I'm thinking to be able to find a control that has ListViewWebPartJSGrid in its id. It is possible that there would be more than one on the page, but that would work out.

[update]

Okay, I figured out how to fetch the control id (you can see the color change):

var $trackingGridID = $("[id$=_ListViewWebPartJSGrid_leftpane_mainTable]").attr("id");
$('#' + trackingGridID).css("background-color", "blue");

//this will fetch:  ctl00_ctl21_g_c3e5fead_d466_4448_9648_dcb92778921d_ListViewWebPartJSGrid_leftpane_mainTable

Now that I have the ID, it is a matter of figuring out how to modify the column widths...

But I want to do something like this:

function SetColumnWidths(column1, column2, column3)...
I made an answer, so moved some of the code to the answer
Source Link
bgmCoder
  • 3.6k
  • 16
  • 61
  • 103

When the GANNT view is being used, how could one resize the columns using jQuery without using the generated controlid (like in this example)? I'm looking for a way to do this in a re-usable javascript function.

I'm thinking to be able to find a control that has ListViewWebPartJSGrid in its id. It is possible that there would be more than one on the page, but that would work out.

[update]

Okay, I figured out how to fetch the control id (you can see the color change):

var $trackingGridID = $("[id$=_ListViewWebPartJSGrid_leftpane_mainTable]").attr("id");
$('#' + trackingGridID).css("background-color", "blue");

//this will fetch:  ctl00_ctl21_g_c3e5fead_d466_4448_9648_dcb92778921d_ListViewWebPartJSGrid_leftpane_mainTable

Now that I have the ID, it is a matter of figuring out how to modify the column widths...

This will modify the width of each column (except for the little "eyebrows"):

$('#' + trackingGridID + " th[role='columnheader']").css("width", "400");

This will fetch the row:

var thisrow = $('#' + trackingGridID).find("tr:eq(2)"); //fetches row by index
$(thisrow).css("background-color", "blue");
    

Here we can fetch an individual cell by index:

var thiscell = $('#' + trackingGridID).find("td:eq(6)"); //fetches cell by index
$(thiscell).css("background-color", "yellow");

I'm still stumped as to the columns however:

But I want to do something like this:

function SetColumnWidths(column1, column2, column3)...

When the GANNT view is being used, how could one resize the columns using jQuery without using the generated controlid (like in this example)? I'm looking for a way to do this in a re-usable javascript function.

I'm thinking to be able to find a control that has ListViewWebPartJSGrid in its id. It is possible that there would be more than one on the page, but that would work out.

[update]

Okay, I figured out how to fetch the control id (you can see the color change):

var $trackingGridID = $("[id$=_ListViewWebPartJSGrid_leftpane_mainTable]").attr("id");
$('#' + trackingGridID).css("background-color", "blue");

//this will fetch:  ctl00_ctl21_g_c3e5fead_d466_4448_9648_dcb92778921d_ListViewWebPartJSGrid_leftpane_mainTable

Now that I have the ID, it is a matter of figuring out how to modify the column widths...

This will modify the width of each column (except for the little "eyebrows"):

$('#' + trackingGridID + " th[role='columnheader']").css("width", "400");

This will fetch the row:

var thisrow = $('#' + trackingGridID).find("tr:eq(2)"); //fetches row by index
$(thisrow).css("background-color", "blue");
    

Here we can fetch an individual cell by index:

var thiscell = $('#' + trackingGridID).find("td:eq(6)"); //fetches cell by index
$(thiscell).css("background-color", "yellow");

I'm still stumped as to the columns however:

But I want to do something like this:

function SetColumnWidths(column1, column2, column3)...

When the GANNT view is being used, how could one resize the columns using jQuery without using the generated controlid (like in this example)? I'm looking for a way to do this in a re-usable javascript function.

I'm thinking to be able to find a control that has ListViewWebPartJSGrid in its id. It is possible that there would be more than one on the page, but that would work out.

[update]

Okay, I figured out how to fetch the control id (you can see the color change):

var $trackingGridID = $("[id$=_ListViewWebPartJSGrid_leftpane_mainTable]").attr("id");
$('#' + trackingGridID).css("background-color", "blue");

//this will fetch:  ctl00_ctl21_g_c3e5fead_d466_4448_9648_dcb92778921d_ListViewWebPartJSGrid_leftpane_mainTable

Now that I have the ID, it is a matter of figuring out how to modify the column widths...

But I want to do something like this:

function SetColumnWidths(column1, column2, column3)...
added more jquery
Source Link
bgmCoder
  • 3.6k
  • 16
  • 61
  • 103

When the GANNT view is being used, how could one resize the columns using jQuery without using the generated controlid (like in this example)? I'm looking for a way to do this in a re-usable javascript function.

I'm thinking to be able to find a control that has ListViewWebPartJSGrid in its id. It is possible that there would be more than one on the page, but that would work out.

[update]

Okay, I figured out how to fetch the control id (you can see the color change):

var $trackingGridID = $("[id$=_ListViewWebPartJSGrid_leftpane_mainTable]").attr("id");
$('#' + trackingGridID).css("background-color", "blue");

//this will fetch:  ctl00_ctl21_g_c3e5fead_d466_4448_9648_dcb92778921d_ListViewWebPartJSGrid_leftpane_mainTable

Now that I have the ID, it is a matter of figuring out how to modify the column widths...

This will modify the width of each column (except for the little "eyebrows"):

$('#' + trackingGridID + " th[role='columnheader']").css("width", "400");

This will fetch the row:

var thisrow = $('#' + trackingGridID).find("tr:eq(2)"); //fetches row by index
$(thisrow).css("background-color", "blue");
    

Here we can fetch an individual cell by index:

var thiscell = $('#' + trackingGridID).find("td:eq(6)"); //fetches cell by index
$(thiscell).css("background-color", "yellow");

I'm still stumped as to the columns however:

But I want to do something like this:

function SetColumnWidths(column1, column2, column3)...

When the GANNT view is being used, how could one resize the columns using jQuery without using the generated controlid (like in this example)? I'm looking for a way to do this in a re-usable javascript function.

I'm thinking to be able to find a control that has ListViewWebPartJSGrid in its id. It is possible that there would be more than one on the page, but that would work out.

[update]

Okay, I figured out how to fetch the control id (you can see the color change):

var $trackingGridID = $("[id$=_ListViewWebPartJSGrid_leftpane_mainTable]").attr("id");
$('#' + trackingGridID).css("background-color", "blue");

//this will fetch:  ctl00_ctl21_g_c3e5fead_d466_4448_9648_dcb92778921d_ListViewWebPartJSGrid_leftpane_mainTable

Now that I have the ID, it is a matter of figuring out how to modify the column widths...

This will modify the width of each column (except for the little "eyebrows"):

$('#' + trackingGridID + " th[role='columnheader']").css("width", "400");

But I want to do something like this:

function SetColumnWidths(column1, column2, column3)...

When the GANNT view is being used, how could one resize the columns using jQuery without using the generated controlid (like in this example)? I'm looking for a way to do this in a re-usable javascript function.

I'm thinking to be able to find a control that has ListViewWebPartJSGrid in its id. It is possible that there would be more than one on the page, but that would work out.

[update]

Okay, I figured out how to fetch the control id (you can see the color change):

var $trackingGridID = $("[id$=_ListViewWebPartJSGrid_leftpane_mainTable]").attr("id");
$('#' + trackingGridID).css("background-color", "blue");

//this will fetch:  ctl00_ctl21_g_c3e5fead_d466_4448_9648_dcb92778921d_ListViewWebPartJSGrid_leftpane_mainTable

Now that I have the ID, it is a matter of figuring out how to modify the column widths...

This will modify the width of each column (except for the little "eyebrows"):

$('#' + trackingGridID + " th[role='columnheader']").css("width", "400");

This will fetch the row:

var thisrow = $('#' + trackingGridID).find("tr:eq(2)"); //fetches row by index
$(thisrow).css("background-color", "blue");
    

Here we can fetch an individual cell by index:

var thiscell = $('#' + trackingGridID).find("td:eq(6)"); //fetches cell by index
$(thiscell).css("background-color", "yellow");

I'm still stumped as to the columns however:

But I want to do something like this:

function SetColumnWidths(column1, column2, column3)...
added another code update
Source Link
bgmCoder
  • 3.6k
  • 16
  • 61
  • 103
Loading
added 93 characters in body
Source Link
bgmCoder
  • 3.6k
  • 16
  • 61
  • 103
Loading
added update
Source Link
bgmCoder
  • 3.6k
  • 16
  • 61
  • 103
Loading
added part of the control id name
Source Link
bgmCoder
  • 3.6k
  • 16
  • 61
  • 103
Loading
Source Link
bgmCoder
  • 3.6k
  • 16
  • 61
  • 103
Loading