Categories | Question details Back To List | ||
Set row to bold Hi all, I have a small problem with a javscript. I want to set a row to bold if a special icon in a cell has been clicked. The code is: var request = false; function DeleteItem( url ) { var sID = mygrid.getSelectedId(); mygrid.setRowTextBold( sID ); if ( confirm( "Eintrag löschen?" )) { // branch for native XMLHttpRequest object if( window.XMLHttpRequest && !( window.ActiveXObject )) { try { request = new XMLHttpRequest(); } catch(e) { request = false; } // branch for IE/Windows ActiveX version } else if( window.ActiveXObject ) { try { request = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { try { request = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { request = false; } } } if( request ) { request.onreadystatechange = DeleteData; request.open( "GET", url, false ); request.send( "" ); } } else { var sID = mygrid.getSelectedId(); alert( sID ); mygrid.setUpdated( sID, false ); //remove update mark mygrid.setRowTextStyle( sID, "text-decoration:none;" ); return false; } } function DeleteData() { // only if request is "loaded" if ( request.readyState == 4 ) { // only if "OK" if ( request.status == 200 || req.status == 304 ) { results = request.responseText; alert( results ); } else { document.getElementById( "error" ).innerHTML = request.statusText; } } } Just after a second click on the icon will set the row bold. Can you help me. Om the way my best best wisches for the New Year. Regards Klaus Answer posted by Support on Jan 07, 2009 15:43 >>Just after a second click on the icon will set the row bold.
The problem is in row ID detection, in fact, the first time when icon clicked it still not selected yet ( click event not reached grid yet ) , so the row ID detected incorrectly which will ruin all other logic. there are two possible solution a) move deleteItem call from img tag to the onRowSelect event ( you can check which cell was clicked and execute delete logic, when cell with image was clicked ) - in such case there will not be any problems with incorrect ID b) hardcode row ID as part of action command for each image ( the ID can be retrieved from native html event object as well - but it will rellay on not documeted properties which is not the safe way ) |