Focal Point
[CLOSED] Column title wrap in a read/write grid: maintain

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/5157096916

May 02, 2012, 04:04 AM
Arvindia
[CLOSED] Column title wrap in a read/write grid: maintain
Hi All,

A quick query. is it possible to wrap the column title in a read/write grid ?

Any suggestions much appreciated.

Thank you

Aravindan

This message has been edited. Last edited by: Kerry,


WebFOCUS 7.6
Windows, All Outputs
May 02, 2012, 07:51 AM
Maintain Wizard
I believe this code will allow multi-line headings in a grid:

{
Form1.Grid1.QuickSetCellTypeEx(2, -1, 2);
Form1.Grid1.QuickSetText(2, -1, "M\na\nr\nk\n"); -* replace this last value with field values.
Form1.Grid1.SetColWidth(2, 20);
Form1.Grid1.RedrawCell(2, -1);
}

The -1 in the first row means the heading. The \n is the carriage return.

Mark
May 02, 2012, 11:00 AM
Arvindia
Hi Mark,

Thanks again for your help. where should i put this piece in a windows onload function. Do you think the windows onload function will be triggered everytime the grid refreshes.

Thank you

Aravindan


WebFOCUS 7.6
Windows, All Outputs
May 02, 2012, 01:59 PM
Maintain Wizard
Here is some code that another client is using in 7.6.11. Basically you can create your own onload event.

Mark

function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
if (oldonload) {
oldonload();
}
func();
}
}
}

addLoadEvent(function() {
var numRows = Form1.Grid1.GetNumberRows();
var count = 0;
for (count = 0; count <= numRows; count++)
{
Form1.Grid1.GetCell(3,count);
var StrCellGet = Form1.Grid1.CellGetText;
if (StrCellGet == 0)
{
Form1.Grid1.GetCell(3, count);
Form1.Grid1.CellSetBackColor(0x0000ff);
Form1.Grid1.CellSetTextColor(0x0000ff);
Form1.Grid1.SetCell(3, count);
Form1.Grid1.RedrawAll();
}
}
})
May 03, 2012, 02:26 AM
Arvindia
Hi Mark,

Thanks for your response. A strange thing is happening.

Firstly , Form1.Grid1.GetNumberRows(); is not functioning. It is not getting rowcount. So i am updating the row count in an invisible editbox and getting it from there. The strange thing is the onload function works when i put an alert on the row-count , the row-count pops up and after i close the onload works .

But when i remove the alert and let the window load as usual without any alerts. The window onload does not do its duty.

I am using the following code

 
addLoadEvent(function() 
{
var numRows = document.getElementById("GridCount").value;
var count = 0;
alert(numRows);
for (count = 0; count < numRows; count++) 
{
evest_prod_non_assets.Grid1.GetCell(5,count);
var StrCellGet = evest_prod_non_assets.Grid1.CellGetText;
if ((StrCellGet !== 'Y') && (StrCellGet !== 'y'))
{
evest_prod_non_assets.Grid1.GetCell(11,count);
evest_prod_non_assets.Grid1.CellSetReadOnly(1);
evest_prod_non_assets.Grid1.SetCell(11,count);
evest_prod_non_assets.Grid1.GetCell(12,count);
evest_prod_non_assets.Grid1.CellSetReadOnly(1);
evest_prod_non_assets.Grid1.SetCell(12,count);
evest_prod_non_assets.Grid1.GetCell(13,count);
evest_prod_non_assets.Grid1.CellSetReadOnly(1);
evest_prod_non_assets.Grid1.SetCell(13,count);
evest_prod_non_assets.Grid1.GetCell(14,count);
evest_prod_non_assets.Grid1.CellSetReadOnly(1);
evest_prod_non_assets.Grid1.SetCell(14,count);
evest_prod_non_assets.Grid1.QuickSetBackColor(11,count,0x00C0C0C0);
evest_prod_non_assets.Grid1.QuickSetBackColor(12,count,0x00C0C0C0);
evest_prod_non_assets.Grid1.QuickSetBackColor(13,count,0x00C0C0C0);
evest_prod_non_assets.Grid1.QuickSetBackColor(14,count,0x00C0C0C0);
evest_prod_non_assets.Grid1.RedrawAll();
}
}
}
)
 



WebFOCUS 7.6
Windows, All Outputs
May 03, 2012, 07:47 AM
Maintain Wizard
This may be due to a timing issue. Basically when the JS performs, the grid may not be fully drawn on the screen. An easy way to test for this is to place the JS code behind a button. When the form displays, click the button and see if it works correctly.

This has been a sporadic issue with the Active X grid.

One thing to try is to call the JS function from mntonload.js. Locate that file in:
ibi\devstudio\ibi_html\javaassist\ini\html\maint

And add the function call. When that file is loaded (automatically) it can kick off your js code.

Mark
May 16, 2012, 05:44 AM
Arvindia
Hi Mark,

Yes you are correct with the timing issue . Bang on Target. I resolved it using a js timedelay function setTimeout and delayed the function call by one second. The onload function now works fine.

Regards

Aravindan


WebFOCUS 7.6
Windows, All Outputs
May 16, 2012, 08:14 AM
Maintain Wizard
Could you please post that delay?

I'm sure it will help other customers!

Mark