EasyUI Forum
May 16, 2024, 11:20:34 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: the onRowContextMenu event of Datagrid Causes another fetch of data from server.  (Read 12956 times)
aemalsayer
Newbie
*
Posts: 7


View Profile
« on: September 02, 2013, 11:22:26 PM »

I am trying to put a context menu to a datagrid but the event causes another POST method to the server. My Javascript for putting context menu is as following:

Code:
$(document).ready(function() {
$('#dg').datagrid({
onRowContextMenu:function(e, field){
e.preventDefault();
$('#mm').menu('show', {
left: e.pageX,
top: e.pageY
});
}
});
});

I have tried the above javascript in the onLoadSuccess event of Datagrid, but still the same. Attached you can see in the firebug which shows two post to get JSON data.

Please help! Smiley
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: September 02, 2013, 11:49:28 PM »

How do you declare your datagrid? If you have the class="easyui-datagrid" in the <table> markup, the datagrid will be created automatically. When call $('#dg').datagrid({...}), the datagrid is re-created again.
Logged
aemalsayer
Newbie
*
Posts: 7


View Profile
« Reply #2 on: September 04, 2013, 01:46:48 AM »

I declared with the class="easyui-datagrid", now when I removed, it reduced one post to the server. But I am wondering why would a javascript binding (i.e. binding the context menu) should recreate the whole datagrid and cause a post back to the server it is an optimization issue.
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #3 on: September 04, 2013, 01:51:13 AM »

Binding context menu does not post any data to server.
Logged
aemalsayer
Newbie
*
Posts: 7


View Profile
« Reply #4 on: September 04, 2013, 03:10:53 AM »

But when I remove the context menu binding code, the extra post to the server goes off, I am using FireBug to see the post to the server, you can check in the screenshot in my first post. I will analyze it in more detail and if could found the reason will post here for others.
BTW, thanks for your usual superb cooperation.
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #5 on: September 04, 2013, 06:05:41 AM »

When call $('#dg').datagrid({...}), the datagrid is created automatically and the data request will be made. This is different from binding context menu. You can bind context menu as below and no data sent to server.
Code:
$('#dg').datagrid('options').onRowContextMenu=function(){
//...
}
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!