EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: kavvson on September 20, 2014, 07:40:52 AM



Title: onExpandRow action onClose?
Post by: kavvson on September 20, 2014, 07:40:52 AM
I have such function

Code:
onExpandRow: function(index,row){
  $('#jloading').html('<img src="themes/default/images/loading.gif">');
                    var ddv = $(this).datagrid('getRowDetail',index).find('div.ddv');
                    ddv.panel({
                        height:1,
                        border:true,
                        cache:false,
                        href:'listdetail.php?listnumb='+row.number,
                        onLoad:function(){
                            $('#dg').datagrid('fixDetailRowHeight',index);
                        }
                    });
                    $('#dg').datagrid('fixDetailRowHeight',index);
$.ajax({
type: "GET",
url: 'listdetail.php?listnumb='+row.number,
success: function (d) {
// replace div's content with returned data
$('#jloading').html(d);
}
});
                },
As you see I added an ajax that shows the same result but in a div container separately from the table
Code:
$('#jloading').html(d);
, now whenever I click + as the expansion it all works fine, but when I do click the -, I would like to empty the container
Code:
#jloading

Do you have any tips?


Title: Re: onExpandRow action onClose?
Post by: stworthy on September 20, 2014, 08:38:40 AM
When click the - icon, the 'onCollapseRow' event fires, in which you can write some code logic to do what you want.


Title: Re: onExpandRow action onClose?
Post by: kavvson on September 20, 2014, 08:41:38 AM
Old Thank you for the onCollapseRow option, but im wondering which can be the most effective way
Code:
.val('') 
would do it properly?[/s]

Code:
onCollapseRow: $('#jinner').html(''),
  also
Code:
.val('') 
doesnt work f.e


Title: Re: onExpandRow action onClose?
Post by: kavvson on September 30, 2014, 07:23:50 AM
Any ideas on this one?


Title: Re: onExpandRow action onClose?
Post by: stworthy on September 30, 2014, 07:53:34 AM
How do you define the '#jloading'? And what do you wish to do when collapse a row? Please describe your issue in more detail.


Title: Re: onExpandRow action onClose?
Post by: kavvson on September 30, 2014, 10:03:09 AM
It only loades a simple data into the div. Onclose I want it to clear the data (http://oi59.tinypic.com/dnj6z9.jpg) [http://oi59.tinypic.com/dnj6z9.jpg]

code :

Container


Code:
<div class="easyui-tabs" id="accord" data-options="tabWidth:112" style="height:500px;">
<div title="Szczegóły" style="padding:10px">
<div id="jloading"></div>
</div>
<div title="Wpisy" style="padding:10px">
<div id="jinner"></div>
</div>
</div>

and my event for onExpand

Code:
                onExpandRow: function(index,row){
$('#jloading').html('<img src="themes/default/images/loading.gif">');
                    var ddv = $(this).datagrid('getRowDetail',index).find('div.ddv');
                    ddv.panel({
                        height:1,
                        border:true,
                        cache:false,
                        href:'listdetail.php?listnumb='+row.number,
                        onLoad:function(){
                            $('#dg').datagrid('fixDetailRowHeight',index);
                        }
                    });
                    $('#dg').datagrid('fixDetailRowHeight',index);
$.ajax({
type: "GET",
url: 'listdetail.php?listnumb='+row.number,
success: function (d) {
// replace div's content with returned data
$('#jloading').html(d);
}
});
$.ajax({
type: "GET",
url: 'listdetailsub.php?listnumb='+row.number,
success: function (d) {
// replace div's content with returned data
$('#jinner').html(d);
}
});
                },

Hope its enough information to help me out.

Whenever I expand I want be able to close it and remove the content ( seems like
Code:
onCollapseRow: $('#jinner').val(''),
doesnt work here )


Title: Re: onExpandRow action onClose?
Post by: stworthy on September 30, 2014, 05:06:38 PM
If you only want to clear the '#jinner' container, call 'empty' or 'html' method after the row is collapsed.
Code:
$('#dg').datagrid({
view: detailview,
onCollapseRow: function(index,row){
$('#jinner').empty();
}
})


Title: Re: onExpandRow action onClose?
Post by: kavvson on October 01, 2014, 02:08:31 AM
Uncaught TypeError: undefined is not a function  after adding the onCollapseRow   VM696:8908 it is
Code:
return $.fn.datagrid.methods[_64d](this,_64e);

whole js.

http://pastebin.com/9VBG7CaU