TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
scropio gurl
NA
147
99.1k
GridView in jquery
Sep 7 2016 6:53 AM
first for test i try to call gridivew in jquery and i use this feature for gridview
https://datatables.net/examples/basic_init/scroll_xy.html
i use this
<
script
type
=
"text/javascript"
>
$(document).ready(function(){
$("#GridView1").prepend($("
<
thead
>
</
thead
>
").append($(this).find("tr:first"))).dataTable({
"aoColumnDefs":[{'bSortable':false,'aTargets':[3]}],
"scrollY":200,
"scrollX":true,
dom:'Bfrtip',
buttons:[
'excelHtml5'
]
});
});
and i create public
DataTable info(id){
function and call this on page load then grid successfully display
but when i call this on button click then gridview not display here i use two function on one button
for display data in gridview i use datatable (function name griddata) and for display data in chart (function name getvo) i use static web method
<scripttype=
"text/javascript"
>
var
strarr=[[
"sfdsdfLi"
,9],[
"Kiwsdfi"
,3],[
"Mixesdfdnuts"
,1],[
"Oranges"
,6],[
"Grapes(bunch)"
,1]];
$(
function
(){
$(
"#<%=search_dat.ClientID%>"
).on(
'click'
,
function
(){
var
fromdate=$(
'[ID*=fromdate]'
).val();
var
todate=$(
'[ID*=todate]'
).val();
var
region=$(
'[ID*=regiondrop]option:selected'
)[0].value;
var
obj={};
var
reg={};
obj.fromdate=fromdate;
obj.todate=todate;
obj.region=region;
reg=region;
Getdata(obj,reg);
return
false
;
});
});
function
Getdata(obj,reg){
$.ajax({
type:
"POST"
,
url:
"WebForm1.aspx/GetVo"
,
data:JSON.stringify(obj),
contentType:
"application/json;charset=utf-8"
,
dataType:
"json"
,
async:
true
,
cache:
false
,
success:
function
(result){
var
myData=JSON.parse(result.d);
console.log(JSON.parse(result.d));
if
(myData!==
null
&&Object.keys(myData).length!==0){
strarr=result.d;
var
myarr=strarr;
$(
"#<%=GridView1.ClientID%>"
).show();
$(
"#container"
).show();
$(
"#Button6"
).show();
$(
"#<%=Label5.ClientID%>"
).hide();
$(
"#<%=Label4.ClientID%>"
).hide();
$(
"#<%=CrystalReportViewer1.ClientID%>"
).hide();
}
else
{
$(
"#<%=GridView1.ClientID%>"
).hide();
$(
"#container"
).hide();
$(
"#cont"
).hide();
$(
"#<%=Label5.ClientID%>"
).show();
$(
"#<%=Label5.ClientID%>"
).text(
"DATANOTFOUND"
);
$(
"#<%=Label4.ClientID%>"
).hide();
return
;
}
$(
'#container'
).highcharts({
chart:{
events:{
load:
function
(event){
var
total=0;
for
(
var
i=0,len=
this
.series[0].yData.length;i<len;i++){
total+=
this
.series[0].yData[i];
}
var
text=
this
.renderer.text(
'Total:'
+total,
this
.plotLeft,
this
.plotTop-20
).attr({
zIndex:5
}).add()
}
},
borderColor:
'Grey'
,
borderWidth:2,
width:500,
height:300,
type:
'pie'
,
options3d:{
enabled:
true
,
alpha:45
}
},
title:{
text:
'Region:'
+reg
},
subtitle:{
text:
'<br>FromDate:'
+obj.fromdate+
'<br>ToDate:'
+obj.todate
},
plotOptions:{
pie:{
innerSize:100,
depth:45,
allowPointSelect:
true
,
cursor:
'pointer'
,
dataLabels:{
enabled:
true
,
format:
'<b>{point.name}</b>:{point.y}'
,
},
showInLegend:
true
}
},
series:[{
name:
'Deliveredamount'
,
data:JSON.parse(myarr)
}]
});
},
error:
function
(error){
alert(
'nodata'
);
}
});
}
button html
<asp:ButtonID=
"search_dat"
class
=
"sear_btn"
value=
"SearchData"
runat=
"server"
Text=
"Button"
OnClick=
"search_dat_Click"
/>
and
protected
void
search_dat_Click(objectsender,EventArgse)
{
griddata(Convert.ToDateTime(fromdate),Convert.ToDateTime(todate),Convert.ToString(regiondrop.SelectedValue));
GridView1.DataSource=dt;
GridView1.DataBind();
}
<asp:GridViewID=
"GridView1"
runat=
"server"
Width=
"100%"
CellPadding=
"0"
Font-Names=
"Verdana"
BackColor=
"White"
BorderColor=
"#CCCCCC"
BorderStyle=
"None"
BorderWidth=
"1px"
Font-Size=
"9pt"
>
<FooterStyleBackColor=
"White"
ForeColor=
"#000066"
/>
<HeaderStyleBackColor=
"#006699"
Font-Bold=
"True"
ForeColor=
"White"
/>
<PagerStyleBackColor=
"White"
ForeColor=
"#000066"
Horizontal/>
<RowStyleForeColor=
"#000066"
/>
<SelectedRowStyleBackColor=
"#669999"
Font-Bold=
"True"
ForeColor=
"White"
/>
<SortedAscendingCellStyleBackColor=
"#F1F1F1"
/>
<SortedAscendingHeaderStyleBackColor=
"#007DBB"
/>
<SortedDescendingCellStyleBackColor=
"#CAC9C9"
/>
<SortedDescendingHeaderStyleBackColor=
"#00547E"
/>
</asp:GridView>
div where chart is display
<divid=
"container"
class
=
"container1"
>
</div>
when i set breakpoint and click on button then griddata not call whereas this container is display on button click ..
any solution?
Reply
Answers (
1
)
How to detect document.ready function present on page
how to remove item using splice