I have been trying to find a way to avoid using alert() to debug since I started web programing, I couldn't find anything in the forum so I figured out the following method, I'm sure someone else has also figured this out, but since I couldn't find any posts I am passing it on.
I started by creating a div in one of the freeform regions <Div id="traceTxt"></> then I added two JavaScript functions
function traceLine(nm,str) {
str1 = $('traceTxt').innerHTML + '<br>' + nm + ' ' + str
$('traceTxt').innerHTML = str1;
}
function traceItem(nm,str) {
str1 = $('traceTxt').innerHTML + nm + ' ' + str
$('traceTxt').innerHTML = str1;
}
The nm parameter is just a way to add descriptive text to the trace, str is the values to display (could be any javascript string)
traceLine() starts a new line in the div, traceItem() adds items to current line
example: in onRowSelect event: traceLine('row select vCompany',vCompany + ' row ' + {grid.object}._selectedRow); will trace: row select vCompany G&G Equipment row 5
traceItem('city',{grid.object}.getValue('G','CITY',{grid.object}._selectedRow); will trace; row select vCompany G&G Equipment row 5 city Austin
In a callback it gets a little more complicated: '
function getComp(e)
...
str = tbl.company + " " + tbl.city
getComp = "traceLine('company city " + js_escape(str) + "');" will trace: company city G&G Equipment Austin
or you could use
str = tbl.company + " city " + tbl.city
getComp = "traceLine('company" + js_escape(str) + "');" will trace: company G&G Equipment city Austin
Hope this helps
I started by creating a div in one of the freeform regions <Div id="traceTxt"></> then I added two JavaScript functions
function traceLine(nm,str) {
str1 = $('traceTxt').innerHTML + '<br>' + nm + ' ' + str
$('traceTxt').innerHTML = str1;
}
function traceItem(nm,str) {
str1 = $('traceTxt').innerHTML + nm + ' ' + str
$('traceTxt').innerHTML = str1;
}
The nm parameter is just a way to add descriptive text to the trace, str is the values to display (could be any javascript string)
traceLine() starts a new line in the div, traceItem() adds items to current line
example: in onRowSelect event: traceLine('row select vCompany',vCompany + ' row ' + {grid.object}._selectedRow); will trace: row select vCompany G&G Equipment row 5
traceItem('city',{grid.object}.getValue('G','CITY',{grid.object}._selectedRow); will trace; row select vCompany G&G Equipment row 5 city Austin
In a callback it gets a little more complicated: '
function getComp(e)
...
str = tbl.company + " " + tbl.city
getComp = "traceLine('company city " + js_escape(str) + "');" will trace: company city G&G Equipment Austin
or you could use
str = tbl.company + " city " + tbl.city
getComp = "traceLine('company" + js_escape(str) + "');" will trace: company G&G Equipment city Austin
Hope this helps
Comment