EasyUI Forum
May 17, 2024, 10:52:25 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: On-the-fly change datagrid view ¿is it possible? [SOLVED]  (Read 5037 times)
Juan Antonio Martínez
Jr. Member
**
Posts: 68



View Profile
« on: May 21, 2015, 09:22:57 AM »

Hi all.

Is it posible to change on-the-fly a datagrid view?. That is:

Code:
function changeView(dg, alternateView) {  
    if (typeof(myConfig.defaultView)==='undefined') myConfig.defaultView=dg.datagrid('opts',view);
    if (needAlternateView()){
        dg.datagrid({view:alternateView});
        dg.datagrid('hideColumn',"columnToHideInAltView");
    } else {
        dg.datagrid({view:myConfig.defaultView});
        dg.datagrid('showColumn',"columnToHideInAltView");
    }
    dg.datagrid('reload');
}

If true, what's the way to initialize new view and reset to default one?
Thanks in advance
« Last Edit: May 21, 2015, 12:51:56 PM by Juan Antonio Martínez » Logged
Juan Antonio Martínez
Jr. Member
**
Posts: 68



View Profile
« Reply #1 on: May 21, 2015, 12:51:34 PM »

OK. this works for me :-)
Code:
function testAndSetView(dg,alternateView) {
    if (needAlternativeView()){
        dg.datagrid({
            view: alternateView,
            // set additional dg options
            groupField: 'NombreEquipo',
            groupFormatter: formatTeamResults
        });
        // fix column visibility on new view
        dg.datagrid('hideColumn',"Logo");
    } else {
        // set default view
        dg.datagrid({view:$.fn.datagrid.defaults.view});
        // fix column visibility for this view
        dg.datagrid('showColumn',"Logo");
    }
    // finally clear datagrid
    dg.datagrid('loadData', {"total":0,"rows":[]});
    // dg.datagrid('reload');
}

Some issues still persist:
- how can I remove alternateView extra options when switching to default?
- when setting new view, datagrid is automagically rendered with old and useless data... any way to avoid this behaviour
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!