Showing posts with label Angular2 ngTable Params Sorting. Show all posts
Showing posts with label Angular2 ngTable Params Sorting. Show all posts

Angular CLI 6 & Material 6 Features

Angular CLI 6 & Material 6 Features



Hai Friends November 1, 2017 Angular 5 Released TypeScript Super Set Script Angular 5 Brings some new features to the popular Javascript Framework for building mobile, desktop and web application. Now Angular cli 6 & Material 6 Features Recently NG-CONF 2018 was organized from  18th April in Salt Lake City, UT. As always this three days conference brought a lot of incredible sessions, workshops, and announcements.

Angular CLI 6 & Material 6 Features
Angular CLI 6 & Material 6 Features
NG-CONF 2018 was started with the session by brad green, misko Hevery and Kara Erickson.

Brad has Introduced 
  1. Clarity Design pattern,
  2. NgRx Library,
  3. StackBlitz
Clarity Design Pattern 

UX guidelines, HTML/CSS framework, and Angular components working together to craft exceptional experience.

NgRx Library

NgRx is becoming popular for Reactive State Management. 
@ngrx provides a set of clean, well-tested libraries for reactive programming in Angular applications.

StackBlitz

StackBlitz online IDE for web application powered by vscode. ReadMore

angularjs single line json data how to display table format split \r\n

angularjs single line json data how to display table format split \r\n






Hi Today Discussed i handle one task default angularjs single line json data how to display table format split \r\n json data single line json data split \r\n first \r\n table heading <th> tag another table data  <td> followus code.

angularjs single line json data how to display table format split \r\n
angularjs single line json data how to display table format split \r\n

 index.html
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<body>

<div ng-app="myApp" ng-controller="Jsondatadisplay">
    <div class="container">
  
      <br>
        <h3>Data Details:</h3>
        <table class="table table-striped" id="myTable2">
            <thead>
            <tr>
                <th data-ng-repeat="tr in tableHeader track by $index">{{tr}}</th>
            </tr>
            </thead>
            <tr data-ng-repeat="data in tableData track by $index">
                <td data-ng-repeat="col in data track by $index">{{ col }}</td>

            </tr>
        </table>

        <div>

        </div>

        <script>
            var app = angular.module('myApp', []);
            app.controller('Jsondatadisplay', function ($scope, $http) {
            
                $http
                    .get("data.json")
                    .then(function (res) {
                        var dataToParse = res.data.Data;
                        var replaced = dataToParse.split("\r\n");
                        $scope.tableHeader = replaced[1].split(",");
                        var tempArray = [];
                        angular.forEach(replaced, function (element) {
                            tempArray.push(element.split(","));
                        });

                        delete tempArray[0];
                        delete tempArray[1];
                        $scope.tableData = tempArray;
                    })
            });
        </script>

</body>
</html>
data.json

json data very largest json data so please click github link and download file Click Here

output Click Here

Angularjs push list elements to an array

Angularjs push list elements to an array


Hi Guys Today Discussed Angularjs push list elemetns to an array view list form data push array same method used ionic framework. controller data array push element angularjs push list elements to an array follows code.

Angularjs push list elements to an array
Angularjs push list elements to an array

var app = angular.module('angularjs-starter', []);

Controller

app.controller('MainCtrl', function($scope) {
   $scope.submitForm = function () {
       alert($scope.choicesMade);
   };

  $scope.radioValue = {};
   
  $scope.choicesMade = [];
  
  $scope.wordsPresent=['King', 'Garden', 'America', 'Sky', 'Potato', 'Germany', 'Rose', 'Whisky', 'Mumbai', 'Walk'];

  $scope.pushToArray = function(item) {
    if ($scope.choicesMade.indexOf($scope.radioValue[item]) > -1) {
      alert("already in choices");
      return;
    }
    $scope.choicesMade.push($scope.radioValue[item]);
  }

  $scope.removeFromArray = function(item) {
    
    var index = $scope.choicesMade.indexOf($scope.radioValue[item].substring(1));
    if (index > -1) {
      $scope.choicesMade.splice(index, 1);  
    }
    

  }
});
html page

<!DOCTYPE html>
<html ng-app="angularjs-starter">
  
  <head lang="en">
    <meta charset="utf-8">
    <title>Custom Plunker</title>
    <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.min.js"></script>
    <link rel="stylesheet" href="style.css">
    <script>
      document.write('<base href="' + document.location + '" />');
    </script>
    <script src="app.js"></script>
  </head>
  
  <body ng-controller="MainCtrl">
          <div ng-repeat="item in wordsPresent">
            <b>{{ item }}</b><br>
            <label><input type="radio" name="name_{{item}}" ng-change="pushToArray(item)" ng-model="radioValue[item]" value="{{item}}"/> Yes</label>
           <label><input type="radio" name="name_{{item}}" ng-change="removeFromArray(item)" ng-model="radioValue[item]" value="_{{item}}"/> No</label>
          </div>
           <pre>{{choicesMade}}</pre>
  </body> 

</html>


Angularjs idle timeout auto go to lock screen

Angularjs idle timeout auto go to lock screen


Hi Guys Today discussed Angularjs idle timeout Auto go to lock screen Frontend developer very looks and pretty sides example 5 mins or 10 mins without mouse overing and not working auto go to lock screen and then enter password go to continue work.
Angularjs idle timeout auto go to lock screen
Angularjs idle timeout auto go to lock screen

Html Page

This Page index page Main Controller Config and this controller used full application working this function. follows code controller code.


Controller.js

function Appctrl($scope, $interval, $document) {
    var int = null;
    var callbacks = [];
    var idleTime = 0;
    
    $scope.isIdle = function() {
        return (idleTime > 0);
$state.go(app.lock);
    };
    
    angular.element($document).bind('mousemove', function(e) {
        idleTime = 0;
        $interval.cancel(int);
        startInterval();
        $scope.$apply();
    });
    
    function startInterval() {
        int = $interval(function() {
         idleTime += 3000;
     }, 3000);
    }
    
    startInterval();
}

Stimulsoft Reports.JS is a platform for generating reports using JavaScript and HTML5. Angularjs

Stimulsoft Reports.JS is a platform for generating reports using JavaScript and HTML5.


Stimulsoft Reports.js is a platform for generating report using javascript and html5. Normally html design and report geneerating and stimulsoft is autometically report generation and connection string your db connection and wrtie query auto function generation report.


DBconnection
dbconnection
Stimulsoft Report is modify design any design easily modifed and watermark and everything is very easy.

View Report
View Report
Include Files:
 <link href="css/demo.css" rel="stylesheet">
 
 <!-- Report Viewer Office2013 style -->
 <link href="css/stimulsoft.viewer.office2013.whiteblue.css" rel="stylesheet">
 
 <!-- Report Designer Office2013 style -->
 <link href="css/stimulsoft.designer.office2013.whiteblue.css" rel="stylesheet">
 
 <!-- Stimusloft Reports.JS -->
 <script src="scripts/stimulsoft.reports.js" type="text/javascript"></script>
 <script src="scripts/stimulsoft.viewer.js" type="text/javascript"></script>
 <script src="scripts/stimulsoft.designer.js" type="text/javascript"></script>

 <!-- Reports -->
 <script src="reports/OnlineStoreSales.js" type="text/javascript"></script>
 <script src="reports/UsersAppleIpad.js" type="text/javascript"></script>
 <script src="reports/SmartphoneBestsellersInQ12015.js" type="text/javascript"></script>
 <script src="reports/SiteStatistics.js" type="text/javascript"></script>
 <script src="reports/HighlightCondition.js" type="text/javascript"></script>
 <script src="reports/Images.js" type="text/javascript"></script>
 <script src="reports/MasterDetail.js" type="text/javascript"></script>
 <script src="reports/MultiColumnList.js" type="text/javascript"></script>
 <script src="reports/SideBySideListWithContainers.js" type="text/javascript"></script>
 <script src="reports/SimpleGroup.js" type="text/javascript"></script>
 <script src="reports/SimpleList.js" type="text/javascript"></script>
 <script src="reports/ParametersSelectingCountry.js" type="text/javascript"></script>

 <!-- Demo data -->


<script>
  var viewer = null;
  var designer = null;
  
  function createViewer() {
   // Specify necessary options for the viewer
   var options = new Stimulsoft.Viewer.StiViewerOptions();
   options.height = "100%";
   options.appearance.scrollbarsMode = true;
   options.toolbar.showDesignButton = true;
   options.toolbar.printDestination = Stimulsoft.Viewer.StiPrintDestination.Direct;
   options.appearance.htmlRenderMode = Stimulsoft.Report.Export.StiHtmlExportMode.Table;

   // Create an instance of the viewer
   viewer = new Stimulsoft.Viewer.StiViewer(options, "StiViewer", false);
   
   // Add the design button event
   viewer.onDesignReport = function (e) {
    this.visible = false;
    if (designer == null) createDesigner();
    designer.visible = true;
    designer.report = e.report;
   };
   
   viewer.renderHtml("viewerContent");
  }
  
  function createDesigner() {
   var options = new Stimulsoft.Designer.StiDesignerOptions();
   options.appearance.fullScreenMode = true;
   options.appearance.htmlRenderMode = Stimulsoft.Report.Export.StiHtmlExportMode.Table;
   
   // Create an instance of the designer
   designer = new Stimulsoft.Designer.StiDesigner(options, "StiDesigner", false);
   
   // Add the exit menu item event
   designer.onExit = function (e) {
    this.visible = false;
    viewer.visible = true;
   }
   
   designer.renderHtml("designerContent");
  }
  
  function setReport(reportObject) {
   // Forcibly show process indicator
   viewer.showProcessIndicator();
   
   // Timeout need for immediate display loading report indicator
   setTimeout(function () {
    // Create a new report instance
    var report = new Stimulsoft.Report.StiReport();
    // Load reports from JSON object
    report.load(reportObject);

    // Remove all connections in report template (they are used in the first place)
    report.dictionary.databases.clear();
    // Registered JSON data specified in the report with same name
    report.regData("Demo", "Demo", Demo);
    // Assign the report to the viewer
    viewer.report = report;
   }, 50);
  }
  
  // Set report button style
  function setReportButton(button) {
   for (var reportName in reportsCollection) {
    var reportButton = document.getElementById(reportName);
    reportButton.isSelected = reportButton == button;
    reportButton.className = reportButton.isSelected ? "ReportButton Selected" : "ReportButton";
   }
  }
  
  // Load first report after the page is loaded
  function onBodyLoad() {
   createViewer();
   selectedButton = document.getElementById("SimpleList");
   onButtonClick(selectedButton, SimpleList);
  }
  
  // Demo Report button events
  // ---
  
  function onButtonClick(button, reportObject) {
   selectedButton.className = "ReportButton";
   button.className = "ReportButton Selected";
   selectedButton = button;
   setReport(reportObject);
  }
  
  function onButtonMouseOver(button) {
   if (button != selectedButton) button.className = "ReportButton Over";
  }
  
  function onButtonMouseOut(button) {
   if (button != selectedButton) button.className = "ReportButton";
  }
 </script>
Html Files
<body onload="onBodyLoad();">
 <div id="designerContent"></div>
 <table class="Main" cellpadding="0" cellspacing="4">
  <tr>
   <td width="150px">
    <table class="LeftPanel" cellpadding="0" cellspacing="0">
     <tr>
      <td height="60px">
       <img style="position: absolute; width: 150px; left: 0px; top: 5px;" src="images/StimulsoftReports.png" />
       <img style="position: absolute; width: 30px; height: 30px; left: 105px; top: 25px;" src="images/Js.png" />
      </td>
     </tr>
     <tr>
      <td height="90%">
       <div class="Buttons">
        <script type="text/javascript">
         // Report id and names for this Demo
         var reportsCollection = {
          "OnlineStoreSales": "Online Store Sales",
          "SimpleList": "Simple List",
          "HighlightCondition": "Highlight Condition",
          "Images": "Images",
          "MasterDetail": "Master-Detail",
          "UsersAppleIpad": "Users Apple Ipad",
          "SmartphoneBestsellersInQ12015": "Smartphone Bestsellers In Q1 2015",
          "MultiColumnList": "Multi-Column List",
          "SimpleGroup": "Simple Group",
          "SiteStatistics": "Site Statistics",
          "ParametersSelectingCountry": "Parameters Selecting Country"
         };
         // Render all report buttons
         for (var reportName in reportsCollection) {
          document.write(
           "<a class=\"ReportButton\" id=\"" + reportName + "\"" + 
           "onmouseover=\"onButtonMouseOver(this)\"" +
           "onmouseout=\"onButtonMouseOut(this)\"" + 
           "onclick=\"onButtonClick(this, " + reportName + ")\">" +
           "<table cellpadding=\"0\" cellspacing=\"0\">" +
           "<tr><td style=\"text-align: center; width: 100%;\"><img src=\"images/" + reportName + ".png\" /></td></tr>" +
           "<tr><td class=\"Caption\">" + reportsCollection[reportName] + "</td></tr>" +
           "</table>" +
           "</a>");
         }
        </script>
       </div>
      </td>
     </tr>
    </table>
   </td>
   <td height="100%" id="viewerContent"></td>
  </tr>
 </table>
</body>
</html>




Angular2 ngTable Params Sorting,Filter and Pagination

Angular2 ngTable Params Sorting,Filter and Pagination


Angular2 ngTable Params Sorting,Filter and Pagination angular Table all feature include sorting pagination and filter customized filter all function include ngtable in looking very pretty and responsive table.

Angular2 ngTable Params Sorting,Filter and Pagination
Angular2 ngTable Params


GetStarted
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.2/angular.js"></script>

<link rel="stylesheet"; href="https://unpkg.com/ng-table@2.0.2/bundles/ng-table.min.css">
<script src="https://unpkg.com/ng-table@2.0.2/bundles/ng-table.min.js"></script>

NgTable Controller
angular.module("myApp", ["ngTable"]);

app.controller('NGTableCtrl', ['$scope', '$filter', '$http', 'ngTableParams', '$resource', '$timeout', '$http', function ($scope, $filter, $http, ngTableParams, $resource, $timeout) {

    'use strict';

    var vm = this;

    $scope.loading = true;
    if ($scope.loading == true) {

        $scope.st = 'whirl standard';
    } else {
        $scope.st = '';
    }
    $http.get('../api/MaidDetails')
        .success(function (largeLoad) {
           
            var data = largeLoad;
      
            vm.data = data;

            vm.changeSelection = function (user) {
       
            };



            vm.tableParams = new ngTableParams({
                page: 1,            // show first page
                count: 1000,          // count per page
                sorting: {
                    ItemAltID: 'desc'     // initial sorting
                }
            }, {
                total: data.length, // length of data
                getData: function ($defer, params) {
                    var orderedData = params.filter() ?
                            $filter('filter')(data, params.filter()) :
                            data;
                    orderedData = params.sorting() ?
    $filter('orderBy')(orderedData, params.orderBy()) :
    orderedData;
                    vm.data = orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count());

                    params.total(orderedData.length); // set total for recalc pagination
                    $defer.resolve(vm.data);;
                }
            });

            // FILTERS
            // ----------------------------------- 

            vm.tableParams2 = new ngTableParams({
                page: 1,            // show first page
                count: 10,          // count per page
                sorting: {
                    ItemAltID: 'asc',     // initial sorting
                    WorkPermitNo: 'asc',
                    NoOfTransfer: 'asc',
                    Discountinued: 'asc',
                    ItemID: 'asc'

                },
                filter: {
                    ItemAltID: '',
                    WorkPermitNo: '',
                    NoOfTransfer: '',
                    Discontinued: '',
                    ItemID: ''




                }
            }, {
                total: data.length, // length of data
                getData: function($defer, params) {
                    var orderedData = params.filter() ?
                            $filter('filter')(data, params.filter()) :
                            data;
                    orderedData = params.sorting() ?
    $filter('orderBy')(orderedData, params.orderBy()) :
    orderedData;
                    vm.data= orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count());

                    params.total(orderedData.length); // set total for recalc pagination
                    $defer.resolve(vm.data);;
                }

            });

        })
     .error(function (error, status) {
         var type = '';
         if (status === '500') {
             type = 'Internal Server Error';
         } else {
             type = 'Page Not Found';
         }
         $scope.short = { message: error, status: status, type: type };
         // console.log($scope.short);

     })
    .finally(function () {
        $scope.loading = false;
        if ($scope.loading === false) {
            $scope.st = '';
        }
        //  $scope.st = 'whirl standard';
        //   ('.whirl standard').show();
    });

}]);


Html Page


<div ng-controller="NGTableCtrl as table" class="container-fluid">
    <div class="bs-example">

        <div id="myAlert" class="alert alert-danger" ng-show="short">
            <a ui-sref="s" class="close" data-dismiss="alert">&times;</a>
            <center><img src="{{app.sitename}}img/errorimage.jpg" /></center>

            <center> <h1>{{short.status}}-{{short.type}}</h1></center>
        </div>
    </div>
  <div class="panel panel-default {{st}}" ng-hide="short">
        <div class="panel-heading">
            <div class="panel-title">Maid Details</div>
        </div>
        <table ng-table="table.tableParams2" show-filter="true" class="table table-bordered table-striped">
            <tbody>

                <tr ng-repeat="user in $data">

                    <td data-title="'ItemAltID'" filter="{ 'ItemAltID': 'text' }" sortable="'ItemAltID'">{{user.ItemAltID}}</td>
                    <td data-title="'WorkPermitNo'" filter="{ 'WorkPermitNo': 'text' }" sortable="'WorkPermitNo'">{{user.WorkPermitNo}}</td>
                    <td data-title="'NoOfTransfer'" filter="{ 'NoOfTransfer': 'text' }" sortable="'NoOfTransfer'">{{user.NoOfTransfer}}</td>
                    <td data-title="'Discontinued'" filter="{ 'Discontinued': 'text' }" sortable="'Discontinued'">{{user.Discontinued}}</td>
                    <td data-title="'ItemID'" filter="{ 'ItemID': 'text' }" sortable="'ItemID'">{{user.ItemID}}</td>

                </tr>
                <!-- <center> <img id="mySpinner" src="img/loading.gif" ng-show="loading" /></center>-->
            </tbody>
        </table>
    </div>
    
</div>