EasyUI Forum
March 29, 2024, 01:25:33 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: reload combogrid after new record added  (Read 4421 times)
jkdoyle
Newbie
*
Posts: 25


View Profile Email
« on: May 23, 2017, 11:07:49 AM »

Hello all

I have a combogrid that I've paired with a "add new record" feature. What I want is fwhen the user creates a new record, the combogrid reloads in order to reflect the newly entered data (correct record desc in the textfield and record selected and scrolled to  in combogrid).  Currently, on submission of the form, I have no problem with reloading the grid or using 'setValue' to set the value and display of the combogrid to the new record. However, due to the number of records, I'm using scrollview with paging set to 10, and I'm having problems figuring out how to get the combogrid to scroll to the newly entered record.  Any help?

Here's an example from the save record function once it has the object result:

Code:
var new_record = result.new_record;
var new_desc = result.new_desc;

var grid = $('#mycombo').combogrid('grid');
grid.datagrid('load');
grid.datagrid('selectRecord',{recordid: new_record});

$('mycombo').combogrid('setValue', {recordid: new_record, desc: new_desc});

Where do I go from here?  I get null or -1 values when I try to use getSelected or getRowIndex. I'm assuming this is because I'm using scrollview?  I am also using a remote datasource in a php file with filtering.

Any help would be appreciated.


Logged
jarry
Administrator
Hero Member
*****
Posts: 2260


View Profile Email
« Reply #1 on: May 24, 2017, 12:13:46 AM »

Once you get the datagrid object, you can call 'getRowIndex' method to get the special row's index and call 'scrollTo' method to scroll to it.
Code:
var index = grid.datagrid('getRowIndex',...);
grid.datagrid('scrollTo', {
  index: index,
  callback: function(){
    // do something here
  }
});

If you just want to append a new row to the datagrid, please call 'appendRow' method instead of reloading all the rows. Please make sure to download the 'datagrid-scrollview.js' file from https://www.jeasyui.com/extension/datagridview.php
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!