Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

jTable jquery with asp .net

Posted on 2013-01-16
2
Medium Priority
?
2,917 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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…
Suggested Courses

604 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