<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
	<title>jQuery Grid Plugin - jqGrid - Topic: Dynamically populate Select in a Subgrid sometimes doesn't work</title>
	<link>http://www.trirand.com/blog/?page_id=393/help/dynamically-populate-select-in-a-subgrid-sometimes-doesnt-work</link>
	<description><![CDATA[Grid plugin]]></description>
	<generator>Simple:Press Version 5.7.5.3</generator>
	<atom:link href="http://www.trirand.com/blog/?page_id=393/help/dynamically-populate-select-in-a-subgrid-sometimes-doesnt-work/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>tony on Dynamically populate Select in a Subgrid sometimes doesn't work</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/dynamically-populate-select-in-a-subgrid-sometimes-doesnt-work#p31003</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/dynamically-populate-select-in-a-subgrid-sometimes-doesnt-work#p31003</guid>
        	        	<description><![CDATA[<p>Hello,</p>
<p>Â </p>
<p>Thanks for the feedback and posting your solution.</p>
<p>Â </p>
<p>Regards</p>
]]></description>
        	        	<pubDate>Thu, 21 Aug 2014 17:17:53 +0300</pubDate>
        </item>
        <item>
        	<title>N@Z on Dynamically populate Select in a Subgrid sometimes doesn't work</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/dynamically-populate-select-in-a-subgrid-sometimes-doesnt-work#p30995</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/dynamically-populate-select-in-a-subgrid-sometimes-doesnt-work#p30995</guid>
        	        	<description><![CDATA[<p>OK, it seems i solved the problem.</p>
<p>in case it halps someone else:</p>
<p>1) in teh fileÂ activity_get1.php I added the code that checks if id==0 and in that case i print an empty SELECT</p>
<p>if($id == 0)<br />
 {<br />
 echo "&#60;select&#62;&#60;option&#62;&#60;/option&#62;&#60;/select&#62;";<br />
 }</p>
<p>Â </p>
<p>2) in the eventÂ onSelectRow, before placing the row in edit mode, I added the following code:</p>
<p>$("#" + subgrid_table_id).setColProp('HID_ACT_id', { editoptions: { dataUrl:'activity_get1.php?id=' + rowId }});</p>
<p>so in the fileÂ activity_get1.php I can retrieve the value of the column HID_CDC_id saved in the database (this because i don't care about the changes of that SELECT because they are already managed in the relative part of code)</p>
<p>Â </p>
<p>3)then i removed all the other parts of code that worked with the selectÂ HID_ACT_id in particular i removed all the following code:</p>
<p>Â $.get('activity_get1.php?id=' + rowId, function(data) {</p>
<p>Â  Â  Â  Â  Â  Â  Â var res = $(data).html();</p>
<p>Â  Â  Â  Â  Â  Â  Â var select_id = "#" + rowId + "_HID_ACT_id";</p>
<p>Â  Â  Â  Â  Â  Â Â <strong>//alert(res);</strong></p>
<p><strong>Â  Â  Â  Â  Â  Â  $(select_id).html(res);</strong></p>
<p>Â  Â  Â  Â  Â  });</p>
<p>Â </p>
<p>anyway thanks for the support tony! great plugin!!!</p>
]]></description>
        	        	<pubDate>Thu, 21 Aug 2014 03:00:42 +0300</pubDate>
        </item>
        <item>
        	<title>N@Z on Dynamically populate Select in a Subgrid sometimes doesn't work</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/dynamically-populate-select-in-a-subgrid-sometimes-doesnt-work#p30994</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/dynamically-populate-select-in-a-subgrid-sometimes-doesnt-work#p30994</guid>
        	        	<description><![CDATA[<p>First of all thanks for your reply.</p>
<p>I read the code of the demo 10 times and tried to change many things in my code but I couldn't get the solution... I didn't get the point unfortunately.</p>
<p>I think the problem is the inline editing because ad I can see in the demo if I used the "form" edit mode i'd be able to make the trick.</p>
<p>I tried mostly everything but in any case SOMETIMES the code doesn't reach the desired SELECT. (like 10% of times i click on a row to enter in edit mode the 2nd SELECT remains empty)</p>
<p>I tried:</p>
<p>jQuery("#" + rowId + '_HID_ACT_id').html("");<br />
jQuery("#" + rowId + '_HID_ACT_id').html(res);</p>
<p>or</p>
<p>$("#" + rowId + '_HID_ACT_id').html(res);</p>
<p>or</p>
<p>//this 10% of times i click gives me the error i posted above</p>
<p>document.getElementById(rowId + '_HID_ACT_id').innerHTML = res;</p>
<p>or even</p>
<p>$("#" + subgrid_table_id).setColProp('HID_ACT_id', { editoptions: { value: data} });</p>
<p>or even</p>
<p>setInterval(function() {$(select_id).html(res);}, 100);</p>
<p>Â </p>
<p>nothing solved the problem.</p>
<p>Â </p>
<p>please, help me becuse i'm stuck.</p>
<p>Â </p>
<p>PS. I even tried to remove the EDITOPTION from the columnÂ HID_ACT_id and populate it programmatically in the OnSelectRow event, but I can't because without that part the SELECT doesn't have an ID and therefore i cannot reach it.</p>
]]></description>
        	        	<pubDate>Thu, 21 Aug 2014 02:22:56 +0300</pubDate>
        </item>
        <item>
        	<title>tony on Dynamically populate Select in a Subgrid sometimes doesn't work</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/dynamically-populate-select-in-a-subgrid-sometimes-doesnt-work#p30955</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/dynamically-populate-select-in-a-subgrid-sometimes-doesnt-work#p30955</guid>
        	        	<description><![CDATA[<p>Hello,</p>
<p>Â </p>
<p>There is a example in our commercial PHP component.</p>
<p>I think you should get the point.</p>
<p>Here is <a href="http://www.trirand.com/blog/phpjqgrid/examples/editing_data/depend_listbox/default.php" target="_blank">the example</a></p>
<p>Â </p>
<p>Kind Regards</p>
]]></description>
        	        	<pubDate>Mon, 18 Aug 2014 11:01:22 +0300</pubDate>
        </item>
        <item>
        	<title>N@Z on Dynamically populate Select in a Subgrid sometimes doesn't work</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/dynamically-populate-select-in-a-subgrid-sometimes-doesnt-work#p30934</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/dynamically-populate-select-in-a-subgrid-sometimes-doesnt-work#p30934</guid>
        	        	<description><![CDATA[<p>Hello,</p>
<p>I've got a grid and a subgrid, in which there are 2 Selects. When I select a row of the subgrid it enters in edit mode as I want, but while I can populate the 1st select (HID_CDC_id) because doesn't have dependencies, I can't manage to populate the 2nd (HID_ACT_id) which depends on the 1st value selected: what appens is that, when I select a row, sometimes both the Selects are properly populated, while sometimes the 2nd remains empty, and I can't understand the scenario which produces this different behavior.</p>
<p>I've tried mostly everything and I noticed that if I put an Alert before setting the html code of the 2nd Select everything works fine and that's another thing that complicate even more the situation for my understanding.</p>
<p>Â </p>
<p>Here's the code... hope someone can helpÂ </p>
<p>jQuery("#sg3").jqGrid({<br />
 Â  url:'server.php?q=1',<br />
 Â  datatype: "xml",<br />
 Â  height: 511,<br />
 Â  width: 780,<br />
 Â  colNames:['ID','Date', 'Notes'],<br />
 Â  colModel:[<br />
 Â  Â  {name:'HIH_ownid',index:'HIH_ownid', width:55, hidden: true, key:true},<br />
 Â  Â  {name:'HIH_date',index:'HIH_date', width:90, editable:true},<br />
 Â  Â  {name:'HIH_notes',index:'HIH_notes', width:100, editable:true}</p>
<p>Â  ],<br />
 Â  editurl: "edit_history_h.php",<br />
 Â  rowNum:8,<br />
 Â  rowList:[8,10,20,30],<br />
 Â  pager: '#psg3',<br />
 Â  sortname: 'HIH_date',<br />
 Â  viewrecords: true,<br />
 Â  sortorder: "desc",<br />
 Â  scrollOffset: 0,Â <br />
 Â  multiselect: false,<br />
 Â  subGrid: true,</p>
<p>Â  onSelectRow: function (rowId) {</p>
<p>Â  Â  var rowIds = $("#sg3").getDataIDs();<br />
 Â  Â  $.each(rowIds, function (index, id) {<br />
 Â  Â  Â  if(id != rowId) $("#sg3").jqGrid ('collapseSubGridRow', id);<br />
 Â  Â  });</p>
<p>Â  Â  if(rowId &#38;&#38; rowId !== lastsel) {<br />
 Â  Â  Â  jQuery('#sg3').jqGrid('restoreRow', lastsel);<br />
 Â  Â  Â  jQuery('#sg3').jqGrid('editRow', rowId, true);<br />
 Â  Â  Â  lastsel = rowId;<br />
 Â  Â  }</p>
<p>Â  },</p>
<p>Â  subGridOptions: {<br />
 Â  Â  "plusicon" : "ui-icon-triangle-1-e",<br />
 Â  Â  "minusicon" : "ui-icon-triangle-1-s",<br />
 Â  Â  "openicon" : "ui-icon-arrowreturn-1-e",</p>
<p>Â  Â  "reloadOnExpand" : false,</p>
<p>Â  Â  "selectOnExpand" : true<br />
 Â  },<br />
 Â  subGridRowExpanded: function(subgrid_id, row_id) {<br />
 Â  Â  var subgrid_table_id, pager_id;<br />
 Â  Â  subgrid_table_id = subgrid_id + "_t";<br />
 Â  Â  pager_id = "p_" + subgrid_table_id;<br />
 Â  Â  $("#" + subgrid_id).html("&#60;table id='" + subgrid_table_id + "' class='scroll'&#62;&#60;/table&#62;&#60;div id='" + pager_id + "' Â  Â  Â  Â  Â  Â  Â class='scroll'&#62;&#60;/div&#62;");<br />
 Â  jQuery("#" + subgrid_table_id).jqGrid({<br />
 Â  Â  url:"subgrid.php?q=2&#38;id=" + row_id,<br />
 Â  Â  datatype: "xml",<br />
 Â  Â  width: 753,<br />
 Â  Â  colNames: ['ID','Cdc','Activity','Hours'],<br />
 Â  Â  colModel: [<br />
 Â  Â  Â  {name:"HID_ownid", index:"HID_ownid", width:80, hidden: true, key:true},</p>
<p>Â  Â  Â  {name:"HID_CDC_id", index:"HID_CDC_id", width:80, sortable: true, editable:true, edittype: "select", editrules: { required: Â  Â  Â  true }, editoptions: {dataUrl:'cdc_get1.php', dataEvents:<br />
 Â  Â  Â  Â  [<br />
 Â  Â  Â  Â  Â  {<br />
 Â  Â  Â  Â  Â  Â  type: 'change',<br />
 Â  Â  Â  Â  Â  Â  fn: function(e) {</p>
<p>Â  Â  Â  Â  Â  Â  Â  $.get('activity_get3.php?id=' + $(this).val(), function(data) {<br />
 Â  Â  Â  Â  Â  Â  Â  Â  var res = $(data).html();<br />
 Â  Â  Â  Â  Â  Â  Â  Â  var select_id = "#" + jQuery("#" + subgrid_table_id).jqGrid('getGridParam', 'selrow') + "_HID_ACT_id";</p>
<p>Â  Â  Â  Â  Â  Â  Â  Â  $(select_id).html(res);</p>
<p>Â  Â  Â  Â  Â  Â  });</p>
<p>Â  Â  Â  Â  Â  Â }<br />
 Â  Â  Â  Â  }<br />
 Â  Â  Â  ]},<br />
 Â  Â  Â  },</p>
<p>Â  Â  Â  {name:"HID_ACT_id", index:"HID_ACT_id", width:70, sortable: true, editable:true, edittype: "select", editrules: { required: Â  Â  Â  true } , editoptions:{dataUrl:'activity_get1.php?id=0'}},<br />
 Â  Â  Â  {name:"HID_hours", index:"HID_hours", width:70, editable:true}</p>
<p>Â  Â  Â  Â ],<br />
 Â  Â  Â  Â editurl: "edit_history_d.php",<br />
 Â  Â  Â  Â rowNum:20,<br />
 Â  Â  Â  Â pager: pager_id,<br />
 Â  Â  Â  Â scrollOffset: 0,<br />
 Â  Â  Â  Â sortname: 'HID_CDC_id',<br />
 Â  Â  Â  Â sortorder: "asc",<br />
 Â  Â  Â  Â height: '100%',</p>
<p>Â  Â  Â  Â onSelectRow: function (rowId) {</p>
<p>Â  Â  Â  Â  Â if(rowId &#38;&#38; rowId !== lastsel_sub)<br />
 Â  Â  Â  Â  Â {<br />
 Â  Â  Â  Â  Â  Â jQuery("#" + subgrid_table_id).jqGrid('restoreRow', lastsel_sub);<br />
 Â  Â  Â  Â  Â  Â jQuery("#" + subgrid_table_id).jqGrid('editRow', rowId, true);</p>
<p>Â  Â  Â  Â  Â  Â $.get('activity_get1.php?id=' + rowId, function(data) {</p>
<p>Â  Â  Â  Â  Â  Â  Â var res = $(data).html();</p>
<p>Â  Â  Â  Â  Â  Â  Â var select_id = "#" + rowId + "_HID_ACT_id";</p>
<p>Â  Â  Â  Â  Â  Â  <strong>//alert(res);</strong></p>
<p><strong>Â  Â  Â  Â  Â  Â  $(select_id).html(res);</strong></p>
<p>Â  Â  Â  Â  Â  });</p>
<p>Â  Â  Â  Â  Â  lastsel_sub = rowId;<br />
 Â  Â  Â  Â  }<br />
 Â  Â  Â  }<br />
 Â  Â });<br />
 Â  Â jQuery("#" + subgrid_table_id).jqGrid('navGrid', "#" + pager_id, {edit:false, add:false, del:false});</p>
<p>Â  Â jQuery("#" + subgrid_table_id).jqGrid('inlineNav', "#" + pager_id);<br />
 Â  }<br />
 });<br />
 jQuery("#sg3").jqGrid('navGrid', '#psg3', {add:false, edit:false, del:false});</p>
<p>jQuery("#sg3").jqGrid('inlineNav', "#psg3");</p>
<p>Â </p>
<p>EDIT:</p>
<p>replacing the rowÂ <strong>$(select_id).html(res);Â </strong>withÂ <strong>document.getElementById(rowId + '_HID_ACT_id').innerHTML = res;Â </strong>firebug gives me the error:</p>
<div class="errorTitle focusRow subLogRow "><span class="errorMessage ">TypeError: document.getElementById(...) is null</span></div>
<div class="errorTrace ">Â </div>
<div class="errorSourceBox errorSource-show focusRow subLogRow ">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr class=" ">
<td class=" ">Â </td>
<td class=" ">
<pre class="errorSourceCode ">document.getElementById(rowId+'_HID_ACT_id').innerHTML = res;</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p>Â </p>
<p>This explains the problem, but not why sometimes the pointed element exists and sometimes not.</p>
<p>So I still don't know how to solve the problem.Â </p>
]]></description>
        	        	<pubDate>Sat, 09 Aug 2014 23:57:36 +0300</pubDate>
        </item>
</channel>
</rss>