locked
Does JQuery DataTable work for CRM 2013 online? RRS feed

  • Question

  • Hi,

    In CRM 2013 online, I am embedding a html WebResource to display a JQuery DataTable object in Account form.  The JQuery DataTable queries an external database thru its restful API.  Somehow, the DataTable does not display data in Account form.  My first question is: does JQuery DataTable work with CRM online?

    Friday, November 14, 2014 10:11 PM

Answers

  • Hi,

    After making Jquery Request get the data into a array and build ur jquery DataTable. Here below code that ı used. newdata is an array object that fill from odata result. In your example it fill from external application API.

    	jQuery("#example").dataTable({
                        "sPaginationType": "full_numbers",
                        "aoColumns": columns,
                        "lengthChange": false,
                        "pageLength": 5,
                        "info": false,
                        "scrollX": true,                
    
                    });
                    if (newdata.length > 0) {
                        var table = $("#example").dataTable();
                        table.fnAddData(newdata);
                    }


    If you find this post helpful then please Vote as Helpful and Mark As Answer. Thanks and Regards, Polat Aydın My blog



    Sunday, November 16, 2014 11:18 AM

All replies

  • Hi,

    I used Jquery DataTable as Webresource. It works perfectly CRM 2013 On-Premise.I think it can work in CRM 2013 online either.


    If you find this post helpful then please Vote as Helpful and Mark As Answer. Thanks and Regards, Polat Aydın My blog

    • Proposed as answer by Guido PreiteMVP Saturday, November 15, 2014 11:31 AM
    Saturday, November 15, 2014 11:08 AM
  • Hi, Polat-

    Thanks for your relay.  I am using JQuery DataTable ajax object to fill the html table.  It does not get data from service API.  It always goes to the error block.  What went wrong?  Thanks.

    var oData = null;
                   
                   // Perform a synchronous oData retrieve
                   $(document).ready(function() {
                           $('#example').dataTable( {
                               "ajax": {
                                      "type": "POST",
                                      "url": oDataSelect,
                                      "data": oData,
                                      "beforeSend": function (XMLHttpRequest) {
                                          XMLHttpRequest.setRequestHeader("Accept", "application/json");
                                          // generate base 64 string from username + password                             
                                          XMLHttpRequest.setRequestHeader("Authorization", "Basic " + Base64.encode("xxxxxxxxxxx"));                                      
                                      },
                                      "success": function (oData, textStatus, XmlHttpRequest) {
                                            alert('OData Select Succeeded: ' + oDataSelect);                                       
                                      },
                                      "error": function (XmlHttpRequest, textStatus, errorThrown) {
                                          alert('OData Select Failed: ' + oDataSelect);
                                      }
                               },
                               "columns": [
                                      { "title": "Name" },
                                      { "title": "Position" },
                                      { "title": "Office" },
                                      { "title": "Extn." },
                                      { "title": "Start date" },
                                      { "title": "Salary" }
                               ]
                          });
                    });

    Saturday, November 15, 2014 10:20 PM
  • please try to use CRM service instead of odata. See the reply from Guido.

    https://social.microsoft.com/Forums/en-US/b2779a64-7ac5-4bde-a338-965159ea9e11/crm-2011-custom-web-page-odata?forum=crmdevelopment

    regards

    Jithesh


    Sunday, November 16, 2014 12:50 AM
  • Hi, Jithesh -

    I happen to name my object as oData.  It is not used to call OrganizationDataService.svc.

    I must call external application's API to retrieve data from another database.  It is a client-side programming using JQuery to call another application API.  I must do client-side programming.  Thanks for your reply.

    Sunday, November 16, 2014 3:12 AM
  • Hi,

    After making Jquery Request get the data into a array and build ur jquery DataTable. Here below code that ı used. newdata is an array object that fill from odata result. In your example it fill from external application API.

    	jQuery("#example").dataTable({
                        "sPaginationType": "full_numbers",
                        "aoColumns": columns,
                        "lengthChange": false,
                        "pageLength": 5,
                        "info": false,
                        "scrollX": true,                
    
                    });
                    if (newdata.length > 0) {
                        var table = $("#example").dataTable();
                        table.fnAddData(newdata);
                    }


    If you find this post helpful then please Vote as Helpful and Mark As Answer. Thanks and Regards, Polat Aydın My blog



    Sunday, November 16, 2014 11:18 AM
  • Hi, Polat:

    Thank you for your working on it.  I have been worked out the situation, display external data in Online CRM 2013 by calling external Restful API, using a server-side plug-in.  Client-side javascript and Jquery did not work, because of the cross-domain limitation.  Thanks for the help.

    Tuesday, February 3, 2015 3:16 PM