EasyUI Forum
May 18, 2024, 11:12:06 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: datagrid groupview - how to call groupFormatter dynamically - SOLVED, thx!  (Read 4861 times)
rannacher
Jr. Member
**
Posts: 52


View Profile
« on: April 11, 2019, 02:08:49 AM »

Hi,

I have a datagrid with groupview and all works fine after data loading.
As long as I am in the function groupFormatter in the datagrid, I can set the group header to whatever I want.

But what I need is that I can also update the group headers dynamically outside of the groupFormatter function,
after user has changed elements in the datagrid. F.e. user can change html slider element in the datagrid
and I want to reflect the changes in the group header without saving and reloading the data from server every time.

i.e. my problem is that in the groupFormatter I can simple return the value for the group header and it gets set,
but if I call such a function later on, I need to manually get the panel or element or whatever of the relevant group header to set it.
What is the correct way to get (and set) each group view header title dynamically (w/o simply reload)?

For title/panel of the datagrid this works well, see below, so I need something similar for each group header.
Code:
                                // -------------------------------------------
                                // statistic for the panel on top
                                // -------------------------------------------
                                var nCount = 0;
                                var nSumWert = 0.0;
                                var rows = $('#dg_skills').datagrid('getRows');
                                for(var j=0; j<rows.length; j++)
                                {
                                  var act_amount = parseFloat(document.getElementById('mySlider'+j).value);
                                  if ( act_amount > 0 )
                                  {
                                    nCount++;
                                    nSumWert += act_amount;
                                  }
                                }
                                var strTitle = 'Mitarbeiter: ['+ (document.getElementById('NAME').value).toUpperCase() +'] hat ' + nCount + ' Skills mit ' +  nSumWert + '/' + (rows.length*3) + ' Punkten (=' + (nSumWert/(rows.length*3)*100).toFixed(2) + '%)';
                                var p = $('#dg_skills').datagrid('getPanel');
                                p.panel('setTitle', strTitle);

Thank you very much!
BR Mike.

« Last Edit: April 15, 2019, 07:29:04 AM by rannacher » Logged
jarry
Administrator
Hero Member
*****
Posts: 2264


View Profile Email
« Reply #1 on: April 13, 2019, 06:24:36 AM »

Please call the 'refreshGroupTitle' method to refresh the group's title.
Code:
$('#dg').datagrid('refreshGroupTitle', groupIndex)
Logged
rannacher
Jr. Member
**
Posts: 52


View Profile
« Reply #2 on: April 14, 2019, 08:31:17 AM »

Thx Jarry,
but even having downloaded version 1.7.6 now, where I see "refreshGroupTitle", this call does not work (not reaching 2nd alert).

Code:
var gcount = $('#dg_skills').datagrid('options').view.groups.length;
for(var i=0; i<gcount; i++)
{
  alert("i=["+i+"] before");
  
  $('#dg_skills').datagrid('refreshGroupTitle', i);  
  
  alert("i=["+i+"] after");
}

Also even if this would work, can I set the group header manually or must this only be in the function "groupFormatter"?
Reason is that when datagrid is created the group header is made of the database,
but now I want it to be made of the elements in the datagrid that the user can modify - f.e. sliders in one column.

Thx again for oyur help!!!
BR Mike.
« Last Edit: April 14, 2019, 04:35:04 PM by rannacher » Logged
jarry
Administrator
Hero Member
*****
Posts: 2264


View Profile Email
« Reply #3 on: April 14, 2019, 08:32:54 PM »

The method 'refreshGroupTitle' is defined in the datagridview extension that should be downloaded from https://www.jeasyui.com/extension/datagridview.php.

Yes, the group title should be defined via 'groupFormatter' function. You can set the group title with any elements and let it depend on the data row. Calling 'refreshRow' or 'updateRow' methods will refresh the group title automatically.
Logged
rannacher
Jr. Member
**
Posts: 52


View Profile
« Reply #4 on: April 15, 2019, 07:09:16 AM »

THX JARRY - SOLVED!
With the info, that 'updateRow' method also automatically refreshes the group title, I can handle this requirement.

BR Mike!
« Last Edit: April 15, 2019, 07:28:27 AM by rannacher » 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!