3.2.0

AddRow() Refreshes row prior to the added row

addRow() seams to refresh the last row immediately prior to the new added row. The values of the input element for this and only this row are always reset to the values in the new row (from the array maybe?) In all the other rows, if the have been changed, the value stays at what it has been changed to it is only the row which is the last row prior to the added row that reverts back yo the original values.
Brad
November 10,
Brad,
If you are reffering to the post 8817.5 ...
I think that's because templates goes in column direction by default, so you need to use a different UI.Input for each cell in same row ( just to properly save every cell Text ).
or save it to the array's row/col pos and then do a :
obj.getRowTemplate(row).refresh();
Give the "Expanding / Collapsing a row " example a try for a similar implementation.
If not the case, then sorry, but a short example is needed to understand the issue :-)
HTH
Carlos
November 11,
Right now my solution is to clone the last row prior to the addRow and then replace the refreshed (the one that is prior to added row). It is a bit of a pain because cloning the row does not clone the attributes in IE so I have replace those as well
Brad
November 11,
Here is a rough version of my code

function add(){var ntoa = document.getElementById(''P2_ROWS'').value;
for(var nr=0;nr<1;nr++){

var num_row = myCells.length;
var lrow = num_row-1;
var lrowid = ''mc1-row-''+lrow;
var anon_id = ''anonymous_cb_0_''+lrow;
var dele_id = ''delete_cb_13_''+lrow;
var lrn = document.getElementById(lrowid);
var anon_ck = document.getElementById(anon_id).checked;
var dele_ck = document.getElementById(dele_id).checked;
var awlrClone = lrn.cloneNode(true);


myCells[num_row]=[''<input type="checkbox" id="anonymous_cb_0_''+num_row+''" name="f04" value="0" onClick="javascript:c=this.checked;i=0;anonymous_item_da(i,c);" />'',''<input type="text" name="f03" size="100" maxlength="255" value="" onBlur="javascript:c=(this.value.length>0); i=0;name_item_da(i,c);" />'',''<input type="text" name="f06" size="25" maxlength="50" value="Michael" onBlur="javascript:c=(this.value.length>0);i=0;item_f03_da(i,c);" />'',''<input type="text" name="f07" size="25" maxlength="50" value="L." />'',''<input type="text" name="f08" size="25" maxlength="50" value="Johnson" onBlur="javascript : c=(this.value.length>0) ;i=0; item_f03_da(i,c);" />'',''<select name="f09" ><option value="%null%">%</option><option value="I" >I</option><option value="II" >II</option><option value="III" >III</option><option value="IV" >IV</option><option value="V" >V</option><option value="Jr." >Jr.</option><option value="Sr." >Sr.</option><option value="" selected="selected"></option></select>'',''<input type="text" name="f10" size="150" maxlength="150" value="218 Blalock Rd." />'',''<input type="text" name="f11" size="25" maxlength="64" value="Houston" />'',''<select name="f12" ><option value="AK" >AK</option><option value="AL" >AL</option><option value="AR" >AR</option><option value="AZ" >AZ</option><option value="CA" >CA</option><option value="CO" >CO</option><option value="CT" >CT</option><option value="DC" >DC</option><option value="DE" >DE</option><option value="FL" >FL</option><option value="GA" >GA</option><option value="HI" >HI</option><option value="IA" >IA</option><option value="ID" >ID</option><option value="IL" >IL</option><option value="IN" >IN</option><option value="KS" >KS</option><option value="KY" >KY</option><option value="LA" >LA</option><option value="MA" >MA</option><option value="MD" >MD</option><option value="ME" >ME</option><option value="MI" >MI</option><option value="MN" >MN</option><option value="MO" >MO</option><option value="MS" >MS</option><option value="MT" >MT</option><option value="NC" >NC</option><option value="ND" >ND</option><option value="NE" >NE</option><option value="NH" >NH</option><option value="NJ" >NJ</option><option selected="selected" value="NM" >NM</option><option value="NV" >NV</option><option value="NY" >NY</option><option value="OH" >OH</option><option value="OK" >OK</option><option value="OR" >OR</option><option value="PA" >PA</option><option value="RI" >RI</option><option value="SC" >SC</option><option value="SD" >SD</option><option value="TN" >TN</option><option value="TT" >TT</option><option value="TX" selected="selected">TX</option><option value="UT" >UT</option><option value="VA" >VA</option><option value="VT" >VT</option><option value="WA" >WA</option><option value="WI" >WI</option><option value="WV" >WV</option><option value="WY" >WY</option><option value="XX" >XX</option></select>'',''<input type="text" name="f13" size="10" maxlength="10" value="77024" />'',''<input type="text" name="f07" size="50" maxlength="50" value="Attorney" />'',''<input type="text" name="f15" size="12" maxlength="2000" value="$250.00" style="text-align:right;"onBlur="javascript:i=0;amount_item_da(i,this);" />'',''<fieldset class="datepicker" id="apex_date_02_01_fieldset"><table summary="" border="0" cellspacing="0" cellpadding="0" class="datepicker" id="apex_date_02_01_holder"><tr><td class="datepicker"><input type="text" name="f02" size="10" maxlength="10" value="08/29/2003" id="apex_date_02_01" /></td><td><a href="javascript:void($p_DatePicker(\''apex_date_02_01\'',\''0\'',\''MM/DD/YYYY\'',\''#666666\'',\''\'',\''\'',\''\'',\''\'',\''2003\'',\''en-us\'',\''Y\'',\''116\'',\''943527195847129\'',\''08\'',\''210\''));"><img src="/i/asfdcldr.gif" alt="Calendar" align="absmiddle" /></a></td></tr></table></fieldset>'',''<input type="hidden" name="f50" value="10320" /><input type="hidden" name="fcs" value="A884FA378C851786DDFE3A33709CB23C" /><input type="checkbox" id="delete_cb_13_''+num_row+''" name="f01" value="" />''];



obj.addRow(num_row);
var lrn2 = document.getElementById(lrowid);
lrn2.parentNode.replaceChild(awlrClone,lrn2);
document.getElementById(anon_id).checked=anon_ck;
document.getElementById(dele_id).checked=dele_ck;


}}


</script>
</body>
</html>');
Brad
November 11,
If using single-click event , it is very common to mix (by mistake) the rise edition with the "detach" ( close the last edit and/but raise a new one by single click on a different cell/row)
So, try to distiguish them by using a top-level var ( and use a timeout just to be sure on switch timing).
Carlos
November 11,
Upppss
I was late again.....
C
November 11,
I have tested this by changing the last and added row in the array on the rowAdd() as far as I can tell from running this test the rowAdd() is refreshing both the newly added and the previous row from the array I have only empirical evidence to support this as I decided not to dig out the rowAdd() function code and examine it but what ever I set as the last two rows of the array is what the last row and the added row of the grid are set to after rowAdd() no matter what the data in the last row was before rowAdd() no of my other row are changed.
Brad
November 11,
Hope it make sense for you ;-) [ I meant the changes ] but ....
That's what I ended up doing ( Note: with NO addRow() )
HTH

<script> 

var myCells =[[]];

function add(){

var num_rowAA = myCells.length;
var num_row = (num_rowAA ==1 && myCells[0].length ==0 ) ? 0 : num_rowAA;

/*
var ntoa = document.getElementById('P2_ROWS').value;
for(var nr=lrow;nr<lrow+1;nr++){


var num_row = myCells.length;
var lrow = num_row-1;

var lrowid = 'mc1-row-'+lrow;
var anon_id = 'anonymous_cb_0_'+lrow;
var dele_id = 'delete_cb_13_'+lrow;
var lrn = document.getElementById(lrowid);
var anon_ck = document.getElementById(anon_id).checked;
var dele_ck = document.getElementById(dele_id).checked;
var awlrClone = lrn.cloneNode(true);
*/

myCells[num_row]=['<input type="checkbox" id="anonymous_cb_0_'+num_row+'" name="f04" value="0" onClick="javascript:c=this.checked;i=0;anonymous_item_da(i,c);" />','<input type="text" name="f03" size="100" maxlength="255" value="" onBlur="javascript:c=(this.value.length>0); i=0;name_item_da(i,c);" />','<input type="text" name="f06" size="25" maxlength="50" value="Michael" onBlur="javascript:c=(this.value.length>0);i=0;item_f03_da(i,c);" />','<input type="text" name="f07" size="25" maxlength="50" value="L." />','<input type="text" name="f08" size="25" maxlength="50" value="Johnson" onBlur="javascript : c=(this.value.length>0) ;i=0; item_f03_da(i,c);" />','<select name="f09" ><option value="%null%">%</option><option value="I" >I</option><option value="II" >II</option><option value="III" >III</option><option value="IV" >IV</option><option value="V" >V</option><option value="Jr." >Jr.</option><option value="Sr." >Sr.</option><option value="" selected="selected"></option></select>','<input type="text" name="f10" size="150" maxlength="150" value="218 Blalock Rd." />','<input type="text" name="f11" size="25" maxlength="64" value="Houston" />','<select name="f12" ><option value="AK" >AK</option><option value="AL" >AL</option><option value="AR" >AR</option><option value="AZ" >AZ</option><option value="CA" >CA</option><option value="CO" >CO</option><option value="CT" >CT</option><option value="DC" >DC</option><option value="DE" >DE</option><option value="FL" >FL</option><option value="GA" >GA</option><option value="HI" >HI</option><option value="IA" >IA</option><option value="ID" >ID</option><option value="IL" >IL</option><option value="IN" >IN</option><option value="KS" >KS</option><option value="KY" >KY</option><option value="LA" >LA</option><option value="MA" >MA</option><option value="MD" >MD</option><option value="ME" >ME</option><option value="MI" >MI</option><option value="MN" >MN</option><option value="MO" >MO</option><option value="MS" >MS</option><option value="MT" >MT</option><option value="NC" >NC</option><option value="ND" >ND</option><option value="NE" >NE</option><option value="NH" >NH</option><option value="NJ" >NJ</option><option selected="selected" value="NM" >NM</option><option value="NV" >NV</option><option value="NY" >NY</option><option value="OH" >OH</option><option value="OK" >OK</option><option value="OR" >OR</option><option value="PA" >PA</option><option value="RI" >RI</option><option value="SC" >SC</option><option value="SD" >SD</option><option value="TN" >TN</option><option value="TT" >TT</option><option value="TX" selected="selected">TX</option><option value="UT" >UT</option><option value="VA" >VA</option><option value="VT" >VT</option><option value="WA" >WA</option><option value="WI" >WI</option><option value="WV" >WV</option><option value="WY" >WY</option><option value="XX" >XX</option></select>','<input type="text" name="f13" size="10" maxlength="10" value="77024" />','<input type="text" name="f07" size="50" maxlength="50" value="Attorney" />','<input type="text" name="f15" size="12" maxlength="2000" value="$250.00" style="text-align:right;"onBlur="javascript:i=0;amount_item_da(i,this);" />','<fieldset class="datepicker" id="apex_date_02_01_fieldset"><table summary="" border="0" cellspacing="0" cellpadding="0" class="datepicker" id="apex_date_02_01_holder"><tr><td class="datepicker"><input type="text" name="f02" size="10" maxlength="10" value="08/29/2003" id="apex_date_02_01" /></td><td><a href="javascript:void($p_DatePicker(\'apex_date_02_01\',\'0\',\'MM/DD/YYYY\',\'#666666\',\'\',\'\',\'\',\'\',\'2003\',\'en-us\',\'Y\',\'116\',\'943527195847129\',\'08\',\'210\'));"><img src="/i/asfdcldr.gif" alt="Calendar" align="absmiddle" /></a></td></tr></table></fieldset>','<input type="hidden" name="f50" value="10320" /><input type="hidden" name="fcs" value="A884FA378C851786DDFE3A33709CB23C" /><input type="checkbox" id="delete_cb_13_'+num_row+'" name="f01" value="" />'];

 // }

//obj.addRow(lrow);

/*
var lrn2 = document.getElementById(lrowid);
lrn2.parentNode.replaceChild(awlrClone,lrn2);
document.getElementById(anon_id).checked=anon_ck;
document.getElementById(dele_id).checked=dele_ck;
*/


obj.setRowCount(myCells.length);
obj.refresh();
}

var obj = new AW.UI.Grid; 
obj.setCellText(myCells); 
obj.setHeaderText("header"); 
obj.setColumnCount(14); 
obj.setRowCount(myCells.length);
document.write(obj); 


    var button = new AW.UI.Button;
    button.setControlText("add row");
   button.onControlClicked = function(){
   add();
   };

    document.write("<br>" + button);

</script>
Carlos
November 12,

This topic is archived.

See also:


Back to support forum