EasyUI Forum

General Category => Bug Report => Topic started by: mikethegeeks on June 10, 2016, 03:22:24 AM



Title: [SOLVED]Nested Subgrid and AppendRow
Post by: mikethegeeks 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.


Title: Re: Nested Subgrid and AppendRow
Post by: jarry 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);
};


Title: Re: Nested Subgrid and AppendRow
Post by: mikethegeeks on June 13, 2016, 03:26:40 AM
Jarry, thanks for your reply,

I hadn't the latest version of 'datagrid-detailview.js'. ???
When I load it the problem is solved.  ;)

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

Thanks a lot,