Getting Null Value first time getting the selected row id.


I am trying to figure why rowId is Null when the radio button is clicked for the first time.

What we have are radio buttons and when one is clicked then it should get its rowId and its value and put it into an input box with a comma separating each row id and its value

eg:13004238~01~01:02, 110012178~01~01:05, 110014742~01~01:03 Here 3004238~01~01 is the row id and : separates the row id and value of the clicked radio button and 02 is the value of the checked radio button.

I get a null value for rowId the first time the radio button is clicked null:04 and after the second click it seems to work. 13004238~01~01:02, 110012178~01~01:05, 110014742~01~01:03

I noticed that before clicking on the radio button if you click on any row, and then click on the radio button, it works.

Can you please advise where I am going wrong ?


var mygrid; $(function() { $("input:radio").click(function() { var selectedId=mygrid.getSelectedRowId(); var clicked = []; $("input[type=radio]:checked").each(function() { clicked.push(selectedId+":"+this.value); }); $("#ANSWER\\.TTQ\\.MENSYS\\.4\\.").val(clicked); }); }); function doInitGrid(){ mygrid.setHeader("Programme,Route,UCAS ID,Name,Fee
Sts,Yr of
Entry,Rsp 1,YrS,Brd,Match,Qual,Grd,Subject,Updated,Conditions,Firm Choice
Not Met
Missed 1
Missed 2
");//0-15 columns mygrid.enableMultiline(true); mygrid.init(); var xmlstr='UBLLAWSING05UBLLAWSING051093824438Mr KS LimO2014Fnicknick2<![CDATA[
]]>\UBLLAWSING05UBLLAWSING051094878913Mr LE Zela-KoortO2014Fnicknick2<![CDATA[
]]>\ UBLLAWSING05UBLLAWSING051095865037Mr HK LekO2014Fnicknick2<![CDATA[
]]>\'; mygrid.parse(xmlstr,function(){ mygrid.forEachRow(function(id) { //adding class to subject cell mygrid.cells(id, 12).cell.className = 'no-ww'; }); }); //Loading the xml } //doInintGrid[/code]

Please, try to call your click function with a timeout:

[code] $(function() {
$(“input:radio”).click(function() {
var selectedId=mygrid.getSelectedRowId();
var clicked = [];

           $("input[type=radio]:checked").each(function() {

Thank you for your reply. We have done it slightly different. Instead of getting the id from the row, we get the id from the div surrounding the radio buttons.


<---- Row id here
<cell type="ro"><![CDATA[<div id="2342342"><div class="rd"><input type="radio" name="130009670101" value="00"></div><div class="rd"><input type="radio" name="130009670101" value="01"></div><div class="rd"><input type="radio" name="130009670101" value="02"></div><div class="rd"><input type="radio" name="130009670101" value="03"></div><div class="rd"><input type="radio" name="130009670101" value="04"></div><div class="rd"><input type="radio" name="130009670101" value="05"></div><div class="rd"><input type="radio" name="130009670101" value="06"></div>]]></cell></row>\ <row id="13005425~01~01"><cell>UBLLAWSING05</cell><cell>UBLLAWSING05</cell><cell>1095865037</cell><cell>Mr HK Lek</cell><cell>O</cell><cell>2014</cell><cell>F</cell><cell><![CDATA[]]></cell><cell><![CDATA[]]></cell><cell><![CDATA[]]></cell><cell><![CDATA[]]></cell><cell><![CDATA[]]></cell><cell><![CDATA[]]></cell><cell><![CDATA[]]></cell><cell>nick</cell><cell>nick2</cell><cell type="ro"><![CDATA[<div class="rd"><input type="radio" name="130054250101" value="00"></div><div class="rd"><input type="radio" name="130054250101" value="01"></div><div class="rd"><input type="radio" name="130054250101" value="02"></div><div class="rd"><input type="radio" name="130054250101" value="03"></div><div class="rd"><input type="radio" name="130054250101" value="04"></div><div class="rd"><input type="radio" name="130054250101" value="05"></div><div class="rd"><input type="radio" name="130054250101" value="06"></div></div>]]></cell>