EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: andyj on November 04, 2016, 04:06:30 AM



Title: $('#dg').datagrid('expandRow', rowIndex); not working
Post by: andyj on November 04, 2016, 04:06:30 AM
I have a datagrid with subgrid.

It's along the lines of http://www.jeasyui.com/tutorial/datagrid/datagrid22.php

With a parent record row expanded, upon double-clicking a child record, a modal form is opened and when submitted, it saves, and reloads the parent datagrid.
I want it to re-select the parent record and expand the parent record.
Everything works fine except it will not expand the record.
Here's my code. I get the parent id from the form, and from that get the rowIndex.
I understand the method is:
$('#dg').datagrid('expandRow', rowIndex);

Code:
function updateRecordTask() {
 var _thisjobid = $('#idtaskformjob_id').combogrid('getValue');// GET job_id (parent record id) from Form
 $('#taskfm').form('submit', {
  url: url,
  onSubmit: function() {
  return $(this).form('validate');
  },
  success: function(result) {
  var result = eval('(' + result + ')');
  if (result.success) {
   $.messager.show({
title: 'Success!',
msg: result.msg
  });
  $('#taskdlg').dialog('close'); // close the dialog
  $('#dg').datagrid('reload'); // reload the user data
  $('#dg').datagrid('selectRecord', _thisjobid); //Select parent record with job_id
  var _rowid = $('#dg').datagrid('getRowIndex',_thisjobid); //Get rowindex of parent record with job_id

  $('#dg').datagrid('expandRow',_rowid); //NOT WORKING - Expand row with rowindex

 } else {
  $.messager.show({
   title: 'Error',
   msg: result.msg
  });
 }
}
});
}

Everything works except the expandRow method....
Any ideas why it won't expand the row?

Thanks :)


Title: Re: $('#dg').datagrid('expandRow', rowIndex); not working
Post by: andyj on November 04, 2016, 04:25:12 AM
I have found a fix. It seems the datagrid needed a little coffee break to update.
I added a setTimeout


Code:
setTimeout(function(){$('#dg').datagrid('expandRow',_rowid)}, 500);

Now working fine.