EasyUI Forum
March 28, 2024, 05:40:32 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: $('#dg').datagrid('expandRow', rowIndex); not working  (Read 8207 times)
andyj
Jr. Member
**
Posts: 57



View Profile
« 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 Smiley
Logged
andyj
Jr. Member
**
Posts: 57



View Profile
« Reply #1 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.
« Last Edit: November 04, 2016, 04:27:19 AM by andyj » Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!