How to add directive to widget serviceportal

sam1212
Mega Expert

Hi All,

I am trying my hands on serviceportal and new to angularjs.

I saw a video explaining how to include dependencies in widget. But it is not working.

So i am trying to pull data from table and display it and trying to do pagination using 3rd party "Pagination Directive"(angularUtils/src/directives/pagination at master · michaelbromley/angularUtils · GitHub ) . I have added the JS file under the dependency but not able to use it .

Can someone help on this. or let me know,do   i need to do any other steps.

working code

<table class="rwd-table" style="background-color: white;">

             

                              <div class="searchResult" >

                                      <tr ng-repeat="task in c.data.tasks">

                                              <td>{{task.number}}</td>

                                              <td>{{task.short_description}}</td>

                                              <tr>

                              </div>

                                      </table>

Added dependency

But when i tried the pagination it didnot .

<table class="rwd-table" style="background-color: white;">

             

                              <div class="searchResult" >

                                      <tr dir-paginate="task in c.data.tasks" | itemsPerPage:5>

                                              <td>{{task.number}}</td>

                                              <td>{{task.short_description}}</td>

                                              <tr>

                              </div>

  </table>

Do i need to add anything in client script .

Client script:

function($scope) {

      var c = this;      

      c.display = function() {                                              

              c.server.update().then(function(data) {              

                     

              })              

      }

      c.display();

}

Any help is appreciated.

28 REPLIES 28

larstange
Mega Sage

Dependency related on widget


find_real_file.png


Dependency


find_real_file.png


JS Include


find_real_file.png


UI Script


find_real_file.png


Hi Lars,



Your post is really helpful. Thank you.  


I am trying to use range.lower,upper and total values to generate a label " Showing 10-20 of 200 results".


Can you help with that ?



Regards,


Nitin Sharma


Hi Lars,



I am trying to implement the same for one of the widget which is displaying closed incident in tabular form.I want to display 10 rows per page.I followed the same steps but it seems that it is not working in my case.


Can you Please guide if there is something that needs to be added to accomplish this.



Regards,


Parul


larstange
Mega Sage

Hi



when you change page you can call a fuction - eg: "on-page-change="getPage(newPageNumber)" and you get the page number to your client controller.


From there it should be easy to generate the numbers you need to display for "Showing 10-20 of 200 results".


You know your page size and you just need to know the number of records you retrieve from the server as well.


Can't I create a new dir-pagination template for this ? Because range.lower, upper and total are already available there. Do you know how I can access these range values in widget HTML ?