time 
设为首页】【收藏本站
当前位置: 主页 > ERP > CRM > 【Microsoft Dynamics CRM 2011教程】49、RetrieveMultiple with JScript JQuery Silverlight LINQ FetchXML and QueryExpression

【Microsoft Dynamics CRM 2011教程】49、RetrieveMultiple with JScript JQuery Silverlight LINQ FetchXML and QueryExpression

时间:2013-03-13 22:05 点击:10637次 字体:[ ]




 【Microsoft Dynamics CRM 2011教程】49、RetrieveMultiple with JScript JQuery Silverlight LINQ FetchXML and QueryExpression_www.fengfly.com

 

 

(一) JScript

JScript一次最多返回50条数据,想要获得更多数据,需要使用__next 对象

 

1. 同步操作返回少于50条数据

 

  1. <html xmlns="http://www.w3.org/1999/xhtml" >  
  2. <head>  
  3.     <script src="ClientGlobalContext.js.aspx" type="text/javascript"></script>  
  4.     <script src="aw_json.js" type="text/javascript"></script>    
  5.     <script src="new_TestLibrary.js" type="text/javascript"></script>  
  6.     <script type="text/javascript">  
  7.         function clearaccountsGrid() {   
  8.             var accountsGrid = document.getElementById("accountsGrid");  
  9.             for (var i = accountsGrid.rows.length - 1; i >= 0; i--) {  
  10.                 accountsGrid.deleteRow(i);  
  11.             }  
  12.         } 
  13.  
  14.         function setElementText(element, text) {  
  15.             ///<summary>  
  16.             /// This function mitigates the fact that IE uses innerText and other browsers use textContent.  
  17.             ///</summary>  
  18.             if (typeof (element.innerText) != "undefined")  
  19.             { element.innerText = text; }  
  20.             else  
  21.             { element.textContent = text; }  
  22.         } 
  23.  
  24.         function Button1_onclick() {  
  25.             clearaccountsGrid();  
  26.             RetrieveAllAccounts()  
  27.         } 
  28.  
  29.         function RetrieveAllAccounts() {             
  30.             try {  
  31.                 var oDataPath = TestLibrary._ODataPath();                 
  32.                 var filter = "/AccountSet?$select=Name";  
  33.                 var retrieveRecordsReq = new XMLHttpRequest();  
  34.                 retrieveRecordsReq.open("GET", oDataPath + filter, false);  
  35.                 retrieveRecordsReq.setRequestHeader("Accept", "application/json");  
  36.                 retrieveRecordsReq.setRequestHeader("Content-Type", "application/json; charset=utf-8");  
  37.                 retrieveRecordsReq.send();  
  38.                 var retrievedResponse = JSON.parse(retrieveRecordsReq.responseText).d;  
  39.                 var totalAccountCount = retrievedResponse.results.length;  
  40.                 setElementText(document.getElementById("totalLabel"), "There are " + totalAccountCount + " accounts"); 
  41.  
  42.                 if (retrievedResponse.results.length > 0) {                                         
  43.                     var accountsGrid = document.getElementById("accountsGrid");  
  44.                     for (var i = 0; i < retrievedResponse.results.length; i++) {  
  45.                         var account = retrievedResponse.results[i];  
  46.                         var row = document.createElement("tr");  
  47.                         var nameCell = document.createElement("td");  
  48.                         setElementText(nameCell, account.Name);  
  49.                         row.appendChild(nameCell);  
  50.                         accountsGrid.appendChild(row);  
  51.                     }                     
  52.                 }  
  53.             }  
  54.             catch (e) {  
  55.                 alert(e.Message);  
  56.             }  
  57.         } 
  58.  
  59.     </script>     
  60.     <title></title>  
  61. </head>  
  62. <body>  
  63.     <label id="totalLabel"></label>  
  64.     <input id="Button1" type="button" value="button" onclick="return Button1_onclick()" />  
  65.     <div id="tableContainer">  
  66.         <table id="accountsTable" rules="groups" summary="This table displays the accounts retrieved.">  
  67.            <tbody id="accountsGrid" />  
  68.          </table>  
  69.     </div>  
  70. </body>  
  71. </html> 



本文地址 : http://www.fengfly.com/plus/view-212061-1.html
标签: LINQ FetchXML CRM 教程 Silverlight QueryExpression Microsoft Dynamics RetrieveMultiple
------分隔线----------------------------
最新评论 查看所有评论
发表评论 查看所有评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
验证码: