scropio gurl

scropio gurl

  • NA
  • 147
  • 97k

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
 
  1. <scripttype="text/javascript">
  2. $(document).ready(function(){
  3. $("#GridView1").prepend($("<thead></thead>").append($(this).find("tr:first"))).dataTable({
  4. "aoColumnDefs":[{'bSortable':false,'aTargets':[3]}],
  5. "scrollY":200,
  6. "scrollX":true,
  7. dom:'Bfrtip',
  8. buttons:[
  9. 'excelHtml5'
  10. ]
  11. });
  12. });
 
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
 
  1. <scripttype="text/javascript">
  2. varstrarr=[["sfdsdfLi",9],["Kiwsdfi",3],["Mixesdfdnuts",1],["Oranges",6],["Grapes(bunch)",1]];
  3. $(function(){
  4. $("#<%=search_dat.ClientID%>").on('click',function(){
  5. varfromdate=$('[ID*=fromdate]').val();
  6. vartodate=$('[ID*=todate]').val();
  7. varregion=$('[ID*=regiondrop]option:selected')[0].value;
  8. varobj={};
  9. varreg={};
  10. obj.fromdate=fromdate;
  11. obj.todate=todate;
  12. obj.region=region;
  13. reg=region;
  14. Getdata(obj,reg);
  15. returnfalse;
  16. });
  17. });
  18. functionGetdata(obj,reg){
  19. $.ajax({
  20. type:"POST",
  21. url:"WebForm1.aspx/GetVo",
  22. data:JSON.stringify(obj),
  23. contentType:"application/json;charset=utf-8",
  24. dataType:"json",
  25. async:true,
  26. cache:false,
  27. success:function(result){
  28. varmyData=JSON.parse(result.d);
  29. console.log(JSON.parse(result.d));
  30. if(myData!==null&&Object.keys(myData).length!==0){
  31. strarr=result.d;
  32. varmyarr=strarr;
  33. $("#<%=GridView1.ClientID%>").show();
  34. $("#container").show();
  35. $("#Button6").show();
  36. $("#<%=Label5.ClientID%>").hide();
  37. $("#<%=Label4.ClientID%>").hide();
  38. $("#<%=CrystalReportViewer1.ClientID%>").hide();
  39. }
  40. else{
  41. $("#<%=GridView1.ClientID%>").hide();
  42. $("#container").hide();
  43. $("#cont").hide();
  44. $("#<%=Label5.ClientID%>").show();
  45. $("#<%=Label5.ClientID%>").text("DATANOTFOUND");
  46. $("#<%=Label4.ClientID%>").hide();
  47. return;
  48. }
  49. $('#container').highcharts({
  50. chart:{
  51. events:{
  52. load:function(event){
  53. vartotal=0;
  54. for(vari=0,len=this.series[0].yData.length;i<len;i++){
  55. total+=this.series[0].yData[i];
  56. }
  57. vartext=this.renderer.text(
  58. 'Total:'+total,
  59. this.plotLeft,
  60. this.plotTop-20
  61. ).attr({
  62. zIndex:5
  63. }).add()
  64. }
  65. },
  66. borderColor:'Grey',
  67. borderWidth:2,
  68. width:500,
  69. height:300,
  70. type:'pie',
  71. options3d:{
  72. enabled:true,
  73. alpha:45
  74. }
  75. },
  76. title:{
  77. text:'Region:'+reg
  78. },
  79. subtitle:{
  80. text:'<br>FromDate:'+obj.fromdate+'<br>ToDate:'+obj.todate
  81. },
  82. plotOptions:{
  83. pie:{
  84. innerSize:100,
  85. depth:45,
  86. allowPointSelect:true,
  87. cursor:'pointer',
  88. dataLabels:{
  89. enabled:true,
  90. format:'<b>{point.name}</b>:{point.y}',
  91. },
  92. showInLegend:true
  93. }
  94. },
  95. series:[{
  96. name:'Deliveredamount',
  97. data:JSON.parse(myarr)
  98. }]
  99. });
  100. },
  101. error:function(error){
  102. alert('nodata');
  103. }
  104. });
  105. }
button html
  1. <asp:ButtonID="search_dat"class="sear_btn"value="SearchData"runat="server"Text="Button"OnClick="search_dat_Click"/>
and
  1. protectedvoidsearch_dat_Click(objectsender,EventArgse)
  2. {
  3. griddata(Convert.ToDateTime(fromdate),Convert.ToDateTime(todate),Convert.ToString(regiondrop.SelectedValue));
  4. GridView1.DataSource=dt;
  5. GridView1.DataBind();
  6. }
  7. <asp:GridViewID="GridView1"runat="server"
  8. Width="100%"CellPadding="0"
  9. Font-Names="Verdana"BackColor="White"BorderColor="#CCCCCC"BorderStyle="None"
  10. BorderWidth="1px"Font-Size="9pt">
  11. <FooterStyleBackColor="White"ForeColor="#000066"/>
  12. <HeaderStyleBackColor="#006699"Font-Bold="True"ForeColor="White"/>
  13. <PagerStyleBackColor="White"ForeColor="#000066"Horizontal/>
  14. <RowStyleForeColor="#000066"/>
  15. <SelectedRowStyleBackColor="#669999"Font-Bold="True"ForeColor="White"/>
  16. <SortedAscendingCellStyleBackColor="#F1F1F1"/>
  17. <SortedAscendingHeaderStyleBackColor="#007DBB"/>
  18. <SortedDescendingCellStyleBackColor="#CAC9C9"/>
  19. <SortedDescendingHeaderStyleBackColor="#00547E"/>
  20. </asp:GridView>
 
div where chart is display
 
  1. <divid="container"class="container1">
  2. </div>
 
when i set breakpoint and click on button then griddata not call whereas this container is display on button click ..
 
any solution?

Answers (1)