jQWidgets Forums
jQuery UI Widgets › Forums › Grid › Grid data request calling double time in button onclick.
Tagged: data request, getJSON, jqxgrid, update data
This topic contains 1 reply, has 2 voices, and was last updated by ivailo 9 years, 9 months ago.
-
Author
-
when i click anchor tag button the grid data request will call double time. i saw in firebug. why…? and my code Attached Bellow
code:
var menu=”;
var settingcolor=”;
var ids=”;
$.getJSON(“index.php?rt=login/getburrlsmenus”,function(json){
$.each(json,function(key,val){
menu+=”“+val[‘bei_shortform’]+”<br><i id='”+val[‘ids’]+”_1′></i> <i id='”+val[‘ids’]+”_2′></i> <i id='”+val[‘ids’]+”_3′></i> “;
});
$(“#EditionMenuData”).append(menu);
$(“#ShowEditionGrid”).hide();
idsAction=$(“#EditionMenuData :first-child”).attr(‘id’);
ids=$(“#EditionMenuData :first-child”).attr(‘name’);
$(“#EditionMenuData #”+idsAction+””).trigger(‘click’);
$(“#EditionMenuData [name=”+ids+”]”).css(“background”,” #D5D5D5″);
});
$.getJSON(“index.php?rt=login/NormalizecolorAssign”,function(json){
$(“#EditionMenuData”).find(“a”).each(function(){
var id=this.name;//it will be used in loading time
$.each(json,function(key,val){
if(val[‘bei_edition_id’]==id){
if(val[‘timecolor’]==’1′){
$(“#EditionMenuData #”+id+”_1”).css(“background-color”, “green”);
}else{
$(“#EditionMenuData #”+id+”_2”).css(“background-color”, “red”);
}
}
});
});
});
}
$(document).on(‘click’, ‘.editionName’, function(e) {
e.preventDefault();
var action=this.id;
var colorname=this.name;
$(“#ShowEditionGrid”).show();
$(“#EditionMenuData a”).css(“background”,”#FFFFFF”);
$(“#EditionMenuData [name=”+colorname+”]”).css(“background”,” #D5D5D5″);
displayBlinflow(action);
});function displayBLinflow(action){
var source3 =
{
datatype: “json”,
datafields: [
{ name: ‘lli_file_name’, type: ‘string’},
{ name: ‘lli_file_processid’, type: ‘number’},
{ name: ‘lli_file_lock’, type: ‘number’ },
{ name: ‘lli_file_sttime’, type: ‘date’ },
{ name: ‘lat_accessType’, type: ‘date’ },
{ name: ‘lli_file_entime’, type: ‘string’ },
{ name: ‘lli_file_status’, type: ‘string’ },
{ name: ‘lli_file_comment’, type: ‘string’ },
],
cache: false,
url: ‘index.php?rt=login/getbrlInflow3/’+id,
updaterow: function (rowid, rowdata, commit) {
commit(true);
}
};
var dataAdapter3= new $.jqx.dataAdapter(source3);var cellsrenderer = function (row, columnfield, value, defaulthtml, columnproperties) {
if(value == 2){
return ‘<span style=”margin: 4px; float: ‘ + columnproperties.cellsalign + ‘;color:red;font-weight:bold;”>Problem File</span>’;
}else if(value == 1){
return ‘<span style=”margin: 4px; float: ‘ + columnproperties.cellsalign + ‘;color:#7E44CE;font-weight:bold;”>Ready to Process</span>’;
}else if( value == 0){
return ‘<span style=”margin: 4px; float: ‘ + columnproperties.cellsalign + ‘;color:orange;font-weight:bold;”>Yet to Start</span>’;
}
}var fileLock = function (row, columnfield, value, defaulthtml, columnproperties) {
if(value == 1){
return ‘<span style=”margin: 4px; float: ‘ + columnproperties.cellsalign + ‘;color:red;font-weight:bold;”>Locked</span>’;
}else if(value == 0){
return ‘<span style=”margin: 4px; float: ‘ + columnproperties.cellsalign + ‘;color:green;font-weight:bold;”>Normal</span>’;
}
}$(“#readytoprocessfiles”).jqxGrid(
{
source: dataAdapter3,
width: ‘100%’,
filterable: true,
sortable: true,
autoheight: true,
pageable: true,
//pagesizeoptions: [’10’, ’30’, ’60’, ‘100’],
pagesize: 12,
showtoolbar: false,
showfilterrow: true,
editable:true,
rendergridrows: function(obj)
{
return obj.data;
},
columns: [{ text: ‘FileName’, datafield: ‘lli_file_name’, pinned: true, width: ‘50%’,sortable:true, filtercondition: ‘starts_with’, editable:false },
{ text: ‘StartTime ‘, datafield: ‘lli_file_sttime’, width: ‘18%’,filtercondition: ‘starts_with’, editable: false, columntype: “datetimeinput”, cellsformat: ‘yyyy-MM-dd HH:mm:ss’ },
{ text: ‘EndTime ‘, datafield: ‘lli_file_entime’, width: ‘18%’,filtercondition: ‘starts_with’, editable: false,columntype: “datetimeinput”, cellsformat: ‘yyyy-MM-dd HH:mm:ss’ },
{ text: ‘Status’, datafield: ‘lli_file_status’, width: ‘15%’,filtercondition: ‘starts_with’, editable: false,cellsrenderer:cellsrenderer },
{ text: ‘Comment’, datafield: ‘lli_file_comment’, width: ‘30%’,filtercondition: ‘starts_with’, editable: false }
],
rendertoolbar: function (toolbar)
{
var me = this;
var container = $(“<div style=’margin: 5px;’></div>”);
var span = $(“<span style=’float: left; margin-top: 4px; margin-right: 4px;’><b>Burrels Inflow</b></span>”);
toolbar.append(container);
container.append(span);
}
});
}help me pls uggent
Hi manikandan.k,
You have to initialize the grid only first time.
Then you have to update only the new data. This may causes you problem.Best Regards,
Ivailo IvanovjQWidgets Team
http://www.jqwidgets.com -
AuthorPosts
You must be logged in to reply to this topic.