Solved

jTable jquery with asp .net

Posted on 2013-01-16
2
2,859 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
ID: 38783825
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
ID: 38784310
Perfect! Thanks you very much
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Debugging Html 8 31
Make check boxes work 8 41
replacing inline javascript with jquery 4 44
How to add custom html-5 element to a dynamically generated link? 4 23
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn how to dynamically set the form action using jQuery.
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)

685 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