web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Dynamics 365 - Render JSON data in javascript grid

(0) ShareShare
ReportReport
Posted on by 30

Hello All,

I am trying to render values to  jsGrid grid and because of some reason it is not displaying any values on the grid.  I am getting the response on this line alert(data.length + " Contact record(s) retrieved.");  with 50 rows. 

Can someone please provide me steps for rendering the data? 

 

$(function() {

$("#jsGrid").jsGrid({
height: "70%",
width: "100%",
paging: true,
pageSize: 15,
pageButtonCount: 5,
pagerContainer: "#externalPager",
pagerFormat: "current page: {pageIndex}    {first} {prev} {pages} {next} {last}    total pages: {pageCount} total items: {itemCount}",
pagePrevText: "<",
pageNextText: ">",
pageFirstText: "<<",
pageLastText: ">>",
pageNavigatorNextText: "&#8230;",
pageNavigatorPrevText: "&#8230;",
data: retrieveMultiple("ContactSet", null, SearchCompleted, null),
fields: [
{ name: "FirstName", type: "text", width: 150 },
{ name: "LastName", type: "text", width: 50 }
]
});

});


function SearchCompleted(data, textStatus, XmlHttpRequest)
{
if (data && data.length > 0)
{
for (var i = 0; i < data.length; i++)
{

}
alert(data.length + " Contact record(s) retrieved.");
}
else
{
alert("No Contact record(s) retrieved.");
}
}

*This post is locked for comments

I have the same question (0)
  • VenkateshVM Profile Picture
    30 on at

    Any solution would help

  • Suggested answer
    Nausher Sayeed Profile Picture
    522 on at

    Hi,

    Check below code for getting value using jason.

    function retrievCollectionUsingXMLHttpRequest(entity, options)

    {

       var req = new XMLHttpRequest();

       var serverURL = Xrm.Page.context.getClientUrl();

       var Query = entity + options;

       var url = serverURL + "/api/data/v8.0/" + Query;

       req.open("GET", url, true);

       req.setRequestHeader("Accept", "application/json");

       req.setRequestHeader("Content-Type", "application/json; charset=utf-8");

       req.setRequestHeader("OData-MaxVersion", "4.0");

       req.setRequestHeader("OData-Version", "4.0");

       req.setRequestHeader("Prefer", "odata.include-annotations=OData.Community.Display.V1.FormattedValue");

       req.onreadystatechange = function ()

       {

           if (this.readyState === 4)

           {

               req.onreadystatechange = null;

               if (this.status === 200)

               {

                   var results = JSON.parse(this.response);

                   for (var i = 0; i < results.value.length; i++)

                   {

                       var _new_doctorid_value = results.value[i]["_new_doctorid_value"];

                       var _new_doctorid_value_formatted = results.value[i]["_new_doctorid_value@OData.Community.Display.V1.FormattedValue"];

                     //  var _new_doctorid_value_lookuplogicalname = results.value[i]["_new_doctorid_value@Microsoft.Dynamics.CRM.lookuplogicalname"];

                       var new_name = results.value[i]["new_name"];

                       Xrm.Utility.alertDialog(_new_doctorid_value_formatted)

                       Xrm.Utility.alertDialog(new_name);

                   }

               } else

               {

                   var error = JSON.parse(this.response).error;

                   Xrm.Utility.alertDialog(error.message);

               }

           }

       };

       req.send();

    }

  • Community Member Profile Picture
    on at

    Hi,

    Tenfold just recently added MS office 365 to their integrations list. Tenfold offers features such as click to dial, automatic call logging, easy note taking and task creation, screen pops on inbound and outbound calls, new lead/contact creation when no matching records, support for cases/opportunities and advanced analytics on the backend. They also support MS Dynamics integration.

    www.tenfold.com/.../microsoft-office-365

  • VenkateshVM Profile Picture
    30 on at

    Thanks Nausher.  Because of some reason I am unable to finish this work. May be I am doing something wrong.  Can you please provide me a sample application using this control http://js-grid.com/demos/  to populate data on the grid?

  • VenkateshVM Profile Picture
    30 on at

    Also I have made some progress with it.  Actually the following code doesn't return any error but it is printing any data on the grid.  I am doing an ajax call on this code.  Please let me know if you find any issue.

      $(function() {

               $("#jsGrid").jsGrid({

                   height: "400px",

                   width: "400px",

                   sorting: true,

                   paging: false,

                   autoload: true,

                   controller: {

                       loadData: function() {

    debugger;

    var accountId = window.parent.Xrm.Page.data.entity.getId();

    var serverUrl = window.parent.Xrm.Page.context.getClientUrl();

    var oDataUri = serverUrl + "/xrmservices/2011/OrganizationData.svc/ContactSet?$select=FirstName&$filter=ParentCustomerId/Id eq guid'" + accountId + "'";

    var jSonArray = new Array();

                       var d = $.Deferred();

    $.ajax({

    type: "GET",

    contentType:  "application/json; charset=utf-8",

    dataType: "json",

    url: oDataUri,

    async:false,

    beforeSend: function (XMLHttpRequest) {      

    XMLHttpRequest.setRequestHeader("Accept", "application/json");

    },

    success: function (data, textStatus, XmlHttpRequest) {

    if (data && data.d != null) {

    jSonArray.push(data.d);

    }

    },

    error: function (XmlHttpRequest, textStatus, errorThrown) {

    alert("Error :  has occured during retrieval of the contacts");

    }

    }).done(function(response){

    d.resolve(jSonArray);

    });

    return d.promise();

                       }

                   },

                   fields: [

                       { name: "FirstName", type: "text", width: 600 }

                   ]

               });

           });

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans