share

RxJS 5 share

by Faisal Pathan

HTML

<script src="https://npmcdn.com/@reactivex/[email protected]/dist/global/Rx.umd.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/datatables/1.10.19/js/jquery.dataTables.min.js"></script>
<div>
<table id="CustomerGrid" class="display" cellspacing="0" width="100%">
            <thead>
                <tr>
					<th>ID</th>
					<th>Title</th>
					<th>Requestor</th>								                    
					<th>Company</th>					
						
                </tr>
            </thead>
<tbody><tr><td>1</td><td>1</td><td>1</td><td>1</td></tr></tbody>
        </table> 
</div>

JavaScript

var web;
var spItems;
var position;
var nextPagingInfo;
var previousPagingInfo;
    //listName = 'Claims',
var pageIndex = 5; // default page index value 
var pageSize = 300; // default page size value 
var Olist;   
var clientcontext;
var camlQuery;
var tableContent='';
var items = [];

// This code runs when the DOM is ready and creates a context object which is needed to use the SharePoint object model  
$(document).ready(function() {
  //  clientcontext = new SP.ClientContext.get_current();
   // oList = //clientcontext.get_web().get_lists().getByTitle("Claims"); 
   // camlQuery = new SP.CamlQuery();

     ///  GetListItems();
	// var rowCount = $('#CustomerGrid tr').length; 
	// console.log(rowCount);
  $('#CustomerGrid').DataTable();
});

function GetListItems() {
    //Set the next or back list items collection position 
    //First time the position will be null 
    camlQuery.set_listItemCollectionPosition(position);

    // Create a CAML view that retrieves all contacts items  with assigne RowLimit value to the query 
    camlQuery.set_viewXml("<View>" +
        "<ViewFields>" +
        "<FieldRef Name='Title'/>" +
        "<FieldRef Name='Requestor'/>" +
        "<FieldRef Name='Company'/>" +
        "</ViewFields>" +
        "<RowLimit>" + pageSize + "</RowLimit></View>");

    spItems = oList.getItems(camlQuery);

    clientcontext.load(spItems);   
	clientcontext.executeQueryAsync(Function.createDelegate(this,this.onSuccess),Function.createDelegate(this,this.onfail));
}

// This function is executed if the above OM call is successful 
// This function render the returns items to html table 
function onSuccess() {

    var listEnumerator = spItems.getEnumerator();
    
    var item;

    while (listEnumerator.moveNext()) {
        item = listEnumerator.get_current();
        items.push(item.get_fieldValues());
        //items.push(item.get_item);
    }
	console.log(items);    
	try{	
			 
		 //table.rows.add($(tableHTML)).draw(); //Append each list...