Coder Social home page Coder Social logo

Pagination events about md-data-table HOT 7 CLOSED

daniel-nagy avatar daniel-nagy commented on July 30, 2024
Pagination events

from md-data-table.

Comments (7)

daniel-nagy avatar daniel-nagy commented on July 30, 2024

How about,

// my controller
$scope.onPageChange = function (page) {
  // do stuff
}
<md-data-table-toolbar layout-align="end">
  <md-data-table-pagination on-change="onPageChange"></md-data-table-pagination>
</md-data-table-toolbar>

I had this implemented at one point then discarded it during a refactor but I could reimplement it again. I agree this would be nice so you wouldn't have to register $watch listeners. Would you care to have the same functionality for the md-filter (will be md-order in the next release for better naming convention) attribute?

from md-data-table.

ahmadhsalim avatar ahmadhsalim commented on July 30, 2024

I think components like md-data-table should have lot of event handlers for everything it does, even md-filter (md-order). The example shown above is good. Perhaps the parameters should be, page and limit.

from md-data-table.

daniel-nagy avatar daniel-nagy commented on July 30, 2024

Okay, this is in spot two of the queue behind row selection backgrounds 👍

from md-data-table.

ahmadhsalim avatar ahmadhsalim commented on July 30, 2024

Can you make it so that the pagination and order change event is NOT run when the page is loaded? Instead it should be run only when the page is changed by the user interactively. I'm having some trouble because the page change event is run when the page is first loaded.
Have a look at the <pagination> directive in this link. I use it in a similar way, but I cannot use the same codes for this because of the event being fired every time the state is loaded.

from md-data-table.

ahmadhsalim avatar ahmadhsalim commented on July 30, 2024

Also I don't understand how you have implemented it in your nutritionController. Where are the onOrderChange and onPageChange event handlers??

from md-data-table.

daniel-nagy avatar daniel-nagy commented on July 30, 2024

I'll admit that this needs more work and the reason the function gets triggered on page load is because the ng-change directive automatically fires in the select dropdown. I'll revisit this after I finish implementing the md-disable-select attribute.

"Also I don't understand how you have implemented it in your nutritionController. Where are the onOrderChange and onPageChange event handlers??"

I think this is just a mistake on my part. I should of removed the attributes in the template as ng-repeat is smart enough to know when the values change.

from md-data-table.

daniel-nagy avatar daniel-nagy commented on July 30, 2024

@ahmadhsalim I'm not positive but I think master branch of Angular Material contains a fix for ngChange firing immediately inside mdSelect. I've pulled down master branch for my current project and it is no longer firing on page load. It looks like they've made some other changes to the template so the styling is not completely accurate but is still very usable.

Now that I have finished md-disable-select I'm going to revisit this. I'd like to see if i can wrap the function that gets passed to mdTrigger in a promise API so even if the developer calls it in their template a loading indicator will be displayed.

update
I've had a moment now to investigate why the function is being triggered unexpectedly and it is actually the same issue that I opened awhile back #3233

from md-data-table.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.