EasyUI Forum
May 20, 2024, 12:33:31 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: [SOLVED]Nested Subgrid and AppendRow  (Read 7489 times)
mikethegeeks
Newbie
*
Posts: 6


View Profile
« on: June 10, 2016, 03:22:24 AM »

Hello evrybody,

I have got a problem with 'nested subgrid'.
When I use 'appendRow', the datagrid is borken. (Please look the screenshot)
To demonstrate the issue, you find a zip file example.

It's necessary to 'expand' all the 'subgrib' and click 'Append Row' button to trigger what seems to be a bug.

Best regard.
PS:Sorry for my approximate english.
« Last Edit: July 18, 2016, 06:48:23 AM by mikethegeeks » Logged
jarry
Administrator
Hero Member
*****
Posts: 2264


View Profile Email
« Reply #1 on: June 10, 2016, 05:53:59 AM »

It is not the bug. You used the static data in the subgrid.
Code:
data:[
{orderdate:'08/23/2012',shippeddate:'12/25/2012',freight:9734}
]
This is why you get the same data when expanding different rows in parent datagrid. Please notice that you should set the 'foreignField' property in the subgrid. When expanding a row, the 'foreignField' parameter value will be post to server. You can return the different data back to browser according to this 'foreignField' value. The code below show how to achieve this feature.
Code:
var conf = {
    options:{
        fitColumns:true,
        columns:[[
            {field:'company',title:'Company Name',width:200},
            {field:'contact',title:'Contact Name',width:200},
            {field:'country',title:'Country',width:200}
        ]],
        data:[
            {companyid:'company1',company:'Speed Info',contact:'Minna John',country:'Sweden'}
        ]
    },
    subgrid:{
        options:{
            fitColumns:true,
            foreignField:'companyid',
            columns:[[
                {field:'orderdate',title:'Order Date',width:200},
                {field:'shippeddate',title:'Shipped Date',width:200},
                {field:'freight',title:'Freight',width:200}
            ]],
            // emulate the loading data from remote server
            loader:function(param,success,error){
                var companyid = param.companyid||'';
                var row = {
                    orderdate:companyid+'-08/23/2012',
                    shippeddate:companyid+'-12/25/2012',
                    freight:parseInt(Math.random()*1000)
                };
                success([row]);
            }
        }
    }
};

function append()
{
    var r={companyid:'company2',company:'test', contact:'test', country:'country'};
    $('#tt').datagrid('appendRow', r);
};
Logged
mikethegeeks
Newbie
*
Posts: 6


View Profile
« Reply #2 on: June 13, 2016, 03:26:40 AM »

Jarry, thanks for your reply,

I hadn't the latest version of 'datagrid-detailview.js'. Huh
When I load it the problem is solved.  Wink

How be sure that is the latest version ? (A dedicated topic in forum for extensions updated ?)

Thanks a lot,
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!