Solved

jTable jquery with asp .net

Posted on 2013-01-16
2
2,801 Views
Last Modified: 2013-01-16
Hi-

I am trying to get jtable working with .net 4.0 but cant seem to get it running...

Here is my code:

_____________________________________________________________________________________________
<WebMethod()> _
    <ScriptMethod(UseHttpGet:=False, ResponseFormat:=Script.Services.ResponseFormat.Json)> _
    Public Function GetPeople() As String
        Dim people As String = "{""Result"":""OK"",""Records"":[{""PersonId"":1,""Name"":""Benjamin Button"",""Age"":17,""RecordDate"":""\/Date(1320259705710)\/""},{""PersonId"":2,""Name"":""Douglas Adams"",""Age"":42,""RecordDate"":""\/Date(1320259705710)\/""},{""PersonId"":3,""Name"":""Isaac Asimov"",""Age"":26,""RecordDate"":""\/Date(1320259705710)\/""},{""PersonId"":4,""Name"":""Thomas More"",""Age"":65,""RecordDate"":""\/Date(1320259705710)\/""}]}"
        Return people
    End Function
_______________________________________________________________________________________________
The web service returns:
{"d":"{\"Result\":\"OK\",\"Records\":[{\"PersonId\":1,\"Name\":\"Benjamin Button\",\"Age\":17,\"RecordDate\":\"\\/Date(1320259705710)\\/\"},{\"PersonId\":2,\"Name\":\"Douglas Adams\",\"Age\":42,\"RecordDate\":\"\\/Date(1320259705710)\\/\"},{\"PersonId\":3,\"Name\":\"Isaac Asimov\",\"Age\":26,\"RecordDate\":\"\\/Date(1320259705710)\\/\"},{\"PersonId\":4,\"Name\":\"Thomas More\",\"Age\":65,\"RecordDate\":\"\\/Date(1320259705710)\\/\"}]}"}
______________________________________________________________________________________________
And my jquery/jtable code:
$(document).ready(function () {

     $('#myjtable').jtable({
         title: 'Table of people',
         actions: {
             listAction: '/GettingStarted/PersonList',
             createAction: '/GettingStarted/CreatePerson',
             updateAction: '/GettingStarted/UpdatePerson',
             deleteAction: '/GettingStarted/DeletePerson'
         },
         fields: {
             PersonId: {
                 key: true,
                 list: false
             },
             Name: {
                 title: 'Author Name',
                 width: '40%'
             },
             Age: {
                 title: 'Age',
                 width: '20%'
             },
             RecordDate: {
                 title: 'Record date',
                 width: '30%',
                 type: 'date',
                 create: false,
                 edit: false
             }
         }
     });

     $('#myjtable').jtable('load');


         });

_____________________________________________________________________________________________

I always seem to get error on the data load.

Any help would be appreciated
0
Comment
Question by:doctor069
2 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
Comment Utility
Use :
$(document).ready(function () {

     $('#myjtable').jtable({
         title: 'Table of people',
         actions: {
              listAction: '/GettingStarted/PersonList',
             createAction: '/GettingStarted/CreatePerson',
             updateAction: '/GettingStarted/UpdatePerson',
             deleteAction: '/GettingStarted/DeletePerson'
         },
         fields: {
             PersonId: {
                 key: true,
                 list: false
             },
             Name: {
                 title: 'Author Name',
                 width: '40%'
             },
             Age: {
                 title: 'Age',
                 width: '20%'
             },
             RecordDate: {
                 title: 'Record date',
                 width: '30%',
                 type: 'date',
                 create: false,
                 edit: false
             }
         }
     });

     $.ajaxSetup({
            dataFilter: function(data) {
                  var msg = jQuery.parseJSON(data);
                  if (msg.hasOwnProperty('d'))
                        return msg.d;
                  else
                        return msg;
            }
      });


    $('#myjtable').jtable('load');


});

More info here : http://encosia.com/never-worry-about-asp-net-ajaxs-d-again/
0
 

Author Closing Comment

by:doctor069
Comment Utility
Perfect! Thanks you very much
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now