Search This Blog

Friday, October 20, 2017

When Data Load In Page Then Used Fliting By Using JQuery Method ( Grep,Map,Filter)

LoadAllDocument();
Call   LoadAllDocument() Before Document .Ready Fuction ()
{
}
 
  var glbDate='';
    function LoadAllDocument()
    {
                 $.ajax({
        url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/GetByTitle('NGODocument')/items?$select=Title,Latitude/Latitude,longitude/Longitude,File/ServerRelativeUrl&$expand=Latitude,longitude,File",
        type: "GET",
        headers: {
            "accept": "application/json;odata=verbose",
        },
        success: function (data) {
            glbDate=data;
        },
        error: function (error) {
            //alert(JSON.stringify(error));
        }
    });
   
 
    function BindNGOOnFilter()
    {
                             var MasterLstName='NGOEmployee';
                            clientContext = new SP.ClientContext.get_current();
                                web = clientContext.get_web();
                                var list = web.get_lists().getByTitle(MasterLstName);
                                var camlQuery = new SP.CamlQuery();
                                //var q = '<View><Query><Where><Eq><FieldRef Name=\'Section\' /><Value Type=\'Choice\'>'+section+'</Value></Eq></Where></Query></View>';
                                //camlQuery.set_viewXml(q);
                                camlQuery.set_viewXml();
                                this.listItems = list.getItems(camlQuery);
                                clientContext.load(listItems);
                                clientContext.executeQueryAsync(Function.createDelegate(this, this.BindMapOnFilterSuccess),Function.createDelegate(this, this.BindMapOnFilterFailed));
    }
   
                function BindNGOOnFilterSuccess()
                {
                                var totalRow=this.listItems.get_count();
                                var listEnumerator = this.listItems.getEnumerator();
                                while (listEnumerator.moveNext()) {
                             var lstitem = listEnumerator.get_current();
                            var vDetail ='';
                          vDetail +='<div><b>Site Name:</b><span class=\'Italic\'>'+isCheckNull(lstitem.get_item("SiteName"))+'</span></div>';
                          var temparr=GetDocument(lstitem.get_item("Latitude"),lstitem.get_item("Longitude"));
                           $.each(temparr, function (key, value)
                                {
                                                vDetail +='<div class=\'Italic\'><a target=\'_blank\' href=\''+value.File.ServerRelativeUrl+'\'>'+value.Title+'</a></div>';      
                                });
        }
    
                }
                function BindNGOOnFilterFailed()
                {
               
                }
   
                function GetDocument(Latitude,longitude)
                {
                                                                var arr='';
                                                                arr = jQuery.grep(glbDate.d.results, function(key,value) {
                                                                                return ( key.Latitude.Latitude == Latitude && key.longitude.Longitude == longitude);
                            });
                            return arr;
                }
                  

No comments:

Post a Comment