Bob Fludder
Posts: 0
Joined: Fri Sep 14, 2012 1:09 am

Change width of grid cell via javascript

Is it possible to change the width of a column in a grid component via javascript ? I'm trying to change the width of the 9th (last) column of a grid so its zero and have the others (that are auto width) dynamically change their width accordingly. Thanks

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Change width of grid cell via javascript

Hi Bob,

Sure, please use the following code:pre$("[name=mobilegridcellName]").width(value);/preWhere 'mobilegridcellName' is a grid cell name,
'value' is a new width value in pixels.

Bob Fludder
Posts: 0
Joined: Fri Sep 14, 2012 1:09 am

Change width of grid cell via javascript

Worked perfectly. Thank you.

Aeneas McBurney
Posts: 0
Joined: Mon Jun 16, 2014 7:49 am

Change width of grid cell via javascript

Hi,

I have tried both of the below and both alerts are giving me the original value of 83, so not changing it. What am I doing wrong?

Have tried....

alert($(this).find("[name=mobilegridcell_255]").width());
$(this).find("[name=mobilegridcell_255]").width("1");
alert($(this).find("[name=mobilegridcell_255]").width());

and .......

alert($(this).find("[name=mobilegridcell_255]").width());
$(this).find("[name=mobilegridcell_255]").width(1);
alert($(this).find("[name=mobilegridcell_255]").width());

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Change width of grid cell via javascript

Hello Aeneas,

Second variant looks right, you don't need to use quotes for width value, as you do in first variant
prealert($(this).find("[name=mobilegridcell_255]").width());
$(this).find("[name=mobilegridcell_255]").width(1);
alert($(this).find("[name=mobilegridcell_255]").width());/pre
Could you please clarify do you have any errors in console?

Aeneas McBurney
Posts: 0
Joined: Mon Jun 16, 2014 7:49 am

Change width of grid cell via javascript

I am running it from the phone app tester. How do I find errors? The event that is firing this code is a swipe left as I want to give the impression that the columns are moving to the side.

Aeneas McBurney
Posts: 0
Joined: Mon Jun 16, 2014 7:49 am

Change width of grid cell via javascript

When I type below into the debugger when app is running null is returned.

$(this).find("[name=mobilegridcell_255]").width()

What is it I'm looking for?

Aeneas McBurney
Posts: 0
Joined: Mon Jun 16, 2014 7:49 am

Change width of grid cell via javascript

I have also tried

var gridcell2=$(this).find("[name=mobilegridcell_271]");
try{
gridcell2.width(50);
alert(gridcell2.width());}
catch(err){
alert(err.message);
}

I get no error but the alert shows original size of 1. It doesn't change to 50 width?

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Change width of grid cell via javascript

Aeneas,

Could you please share your app with support and tell us its name?

Return to “Issues”