Solved

jTable jquery with asp .net

Posted on 2013-01-16
2
2,820 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Requirements JQuery 1.6+ HTML CSS Introduction This article was inspired by an EE question (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28372511.html) on how to make a page show some balloons animate up a page…
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 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…

914 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

19 Experts available now in Live!

Get 1:1 Help Now