Giter Club home page Giter Club logo

aha-table's Introduction

<aha-table> Bower Version

A Polymer element for a searchable, sortable, paginatable, inline-editable, selectable, copyable, removable, movable table/grid.

Demo

Check it live!

Performance Test!

Install

Install the component using Bower:

$ bower install aha-table --save

Or download as ZIP.

Usage

  1. Import Web Components' polyfill:

    <script src="bower_components/webcomponentsjs/webcomponents.min.js"></script>
  2. Import Custom Element:

    <link rel="import" href="bower_components/aha-table/dist/aha-table.html">
  3. Start using it!

    <aha-table></aha-table>
    <aha-table
          selectable
          copyable
          removable
          movable
          seachable
          pagesize="20"
          pagesizetitle="Page Size:"
          summarytitle="Viewing">
    
          <aha-column name="title"
              type="string"
              sortable
              searchable
              required
              placeholder="Empty Field Placeholder Text"
              default=""
              hint="a hint in column header">
          </aha-column>
     </aha-table>

<aha-table>

Options

Attribute Options Default Description
data Array [] data for this table, need to set in JS.
selectable Boolean False if selection box is displayed
searchable Boolean False if search row is displayed
copyable Boolean False if copy handler is displayed
removable Boolean False if remove handler is displayed
movable Boolean False if move up/down handler is displayed
pagesize Number 10 record set size for each page
data-sizelist Array [5, 10, 20, 50, 100] list for page size dropdown
selecttitle String '' title for select checkbox
selectalltitle String '' title for selectall checkbox
copytitle String '' title for copy indicator
removetitle String '' title for remove indicator
movedowntitle String '' title for move down indicator
moveuptitle String '' title for move up indicator
sorttitle String '' title for sortable column
edittitle String '' title for editable data cell
searchtitle String '' title for search filter row toggler
firsttitle String '' title for first page clicker
previoustitle String '' title for previous page clicker
nexttitle String '' title for next page clicker
lasttitle String '' title for last page clicker
pagetext String '' text before current page number
pageoftext String '' text between page range and total page number
pagesizetext String '' text before page size dropdown
summarytitle String '' text before pagination summary
itemoftext String '' text between item count range and total item number

Events

Name Arguments Description
after-invalid Event call after saving a cell by it's invalid
after-td-click Event call after user click a cell, usually after this cell is editable
after-td-dbclick Event call after user dbclick a cell
before-create Event call before a record is created internally
after-create Event call after a record is created internally
before-copy Event call before a record is copyed from another internally
after-copy Event call after a record is copyed from another internally
before-save Event call before a record is saved from another internally
after-save Event call after a record is saved from another internally
before-select Event call before a record is selected
after-select Event call after a record is selected
before-remove Event call before a record is removed internally
after-remove Event call after a record is removed internally
before-move-down Event call before a record is moved down
after-move-down Event call after a record is moved down
before-move-up Event call before a record is moved up
after-move-up Event call after a record is moved up

<aha-column>

Provides you a declarative way to define column meta.

Options

Attribute Options Default Description
name String '' name of the column
label String '' this text woll be displayed as the column name in table header.
type String '' one of: string, text, choice, boolean, date, time, datetime
sortable Boolean False if this column is sortable
searchable Boolean False if this column is searchable
editable Boolean False if this column is editable
required Boolean False if this column is required, Event 'after-invalid' will be invoked
placeholder String '' this text will be displayed when this cell is empty
default String '' default value, applied at creation
data-choices Array [] options for select dropdown, in editing and searching.
hint String '' this text will be displayed at the column header for instruction.
searchplaceholder String '' this text will be displayed in search filter input box.
renderer String undefined function name to format the object being displayed

Browser Compatability

By following http://www.polymer-project.org/docs/polymer/databinding-compat.html , this should be working on all latest version of browsers.

IE Chrome Firefox Opera Safari
IE 10+ ✔ Latest ✔ Latest ✔ Latest ✔ Latest ✔

Development

In order to run it locally you'll need to fetch some dependencies and a basic server setup.

  1. Install Bower & Grunt:

    $ [sudo] npm install -g bower grunt-cli
  2. Install local dependencies:

    $ bower install && npm install
  3. To test your project, start the development server and open http://localhost:8000.

    $ grunt server
  4. Once you finish developing it, build the distribution files and publish it on Bower.

    $ grunt build
    $ bower register aha-table https://github.com/liuwenchao/aha-table
  5. deploy

    $ git add * && git commit && git push
    $ grunt deploy

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -m 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

History

For detailed changelog, check Releases.

License

MIT License

aha-table's People

Contributors

addyosmani avatar eddier avatar liuwenchao avatar netopyr avatar robdodson avatar williamqafe avatar zenorocha avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aha-table's Issues

<aha-column> doesn't work when used inside <template>

Hi! First of all, thank for for the impressive work on this very useful component.

I've run into an issue that I would like to report here. When I'm trying to use the declarative way to specify column-meta data the <aha-column>, that should provide this meta-data, isn't working when I try to use it inside a template (I'm using the aha-table as a part of another component inside a <template>-tag).

I've done a small amount of debugging of this issue, and it seems that it has trouble finding childnodes for the <aha-table> in the ready-method:

ready: function() {
  var children = this.children || this.impl.children;
  if (children.length) {
  this.meta = children.array();
...

I will now provide a little more information about how I'm using the aha-table. As I mentioned before, I'm using it inside another components <template>-tag. The data attribute on the table is bound to a variable that is eventually set by a <core-ajax>-component. Maybe some of these details could lead to the reason for the bug, because it seems like the aha-table hasn't got any children when the data hasn't been set for it yet, and therefore aren't seeing the aha-columns at this point. I don't know, I'm just thinking out loud here and providing a few thoughts that might or might not help :)

json dom-repeat

How do you add a dom-repeat for the row data? this is what I did and it works, but I need a polymer approach.

 var themed  = document.getElementById("themed");

  var events = jQuery.ajax({
    url: '/elements/services/invoices_resume.json',
    type: 'GET',
    dataType: 'json',
    complete: function(xhr, textStatus) {
      console.log(textStatus);
    },
    success: function(data, textStatus, xhr) {
      themed.data = JSON.parse(JSON.stringify(data));
      console.log(data);
    },
    error: function(xhr, textStatus, errorThrown) {
      console.log(errorThrown);
    }
  });

add support for Polymer 1.2.0

now it generate an error
Uncaught InvalidCharacterError: Failed to execute 'setAttribute' on 'Element': 'value$' is not a valid attribute name.Polymer.Annotations._parseNodeAttributeAnnotation @ polymer.html:183Polymer.Annotations._parseNodeAttributeAnnotations @ polymer.html:162Polymer.Annotations._parseElementAnnotations @ polymer.html:106Polymer.Annotations._parseNodeAnnotations @ polymer.html:28Polymer.Annotations._parseChildNodesAnnotations @ polymer.html:130Polymer.Annotations._parseElementAnnotations @ polymer.html:104Polymer.Annotations._parseNodeAnnotations @ polymer.html:28Polymer.Annotations.parseAnnotations @ polymer.html:24Polymer.Annotations._parseTemplate @ polymer.html:140Polymer.Annotations._parseChildNodesAnnotations @ polymer.html:120Polymer.Annotations._parseElementAnnotations @ polymer.html:104Polymer.Annotations._parseNodeAnnotations @ polymer.html:28Polymer.Annotations._parseChildNodesAnnotations @ polymer.html:130Polymer.Annotations._parseElementAnnotations @ polymer.html:104Polymer.Annotations._parseNodeAnnotations @ polymer.html:28Polymer.Annotations._parseChildNodesAnnotations @ polymer.html:130Polymer.Annotations._parseElementAnnotations @ polymer.html:104Polymer.Annotations._parseNodeAnnotations @ polymer.html:28Polymer.Annotations.parseAnnotations @ polymer.html:24Polymer.Annotations._parseTemplate @ polymer.html:140Polymer.Annotations._parseChildNodesAnnotations @ polymer.html:120Polymer.Annotations._parseElementAnnotations @ polymer.html:104Polymer.Annotations._parseNodeAnnotations @ polymer.html:28Polymer.Annotations._parseChildNodesAnnotations @ polymer.html:130Polymer.Annotations._parseElementAnnotations @ polymer.html:104Polymer.Annotations._parseNodeAnnotations @ polymer.html:28Polymer.Annotations.parseAnnotations @ polymer.html:24Polymer.Annotations._parseTemplate @ polymer.html:140Polymer.Annotations._parseChildNodesAnnotations @ polymer.html:120Polymer.Annotations._parseElementAnnotations @ polymer.html:104Polymer.Annotations._parseNodeAnnotations @ polymer.html:28Polymer.Annotations._parseChildNodesAnnotations @ polymer.html:130Polymer.Annotations._parseElementAnnotations @ polymer.html:104Polymer.Annotations._parseNodeAnnotations @ polymer.html:28Polymer.Annotations._parseChildNodesAnnotations @ polymer.html:130Polymer.Annotations._parseElementAnnotations @ polymer.html:104Polymer.Annotations._parseNodeAnnotations @ polymer.html:28Polymer.Annotations.parseAnnotations @ polymer.html:24Polymer.Base._addFeature._prepAnnotations @ polymer.html:274Polymer.Base._addFeature._registerFeatures @ polymer.html:3364Polymer.Base.registerCallback @ polymer-micro.html:144desugar @ polymer-micro.html:73window.Polymer @ polymer-micro.html:57(anonymous function) @ aha-table.html:380
paper-input-container.html:543 /deep/ combinator is deprecated. See https://www.chromestatus.com/features/6750456638341120 for more details.

How to implement delete/edit

I added two paper-fab tag for edit and delete respectively. I am trying to fire an on-tap, on-click event but unable to do that, its simply do not call the function on on-tap while function is already defined.

My backend is in firebase. I just need to call a function and pass an key as parameter on on-tap event.

Can I do that by placing edit/delete in a column for each row?
Or there anything else simple trick that I am missing?

Need options for cross column validation

Say I have column A and column B.
Column A has some values, column B has dropdown list of data types. Based on the data type selected say string or numeric I need to validate data in column A and make user edit column A to match the data type. Currently it allows same column edit and validation, can we do cross column validation also?
Thanks in advance.

aha-table event for “selectable” checkbox

Hi,
I am trying to implement aha-table using Polymer Js. While creating the table I have kept "selectable" attribute true and as expected I am getting the checkboxes before each row, so, I would like to know is there a way to handle/catch the check/unckeck event of such checkboxes. I am able to handle the cell click event for a cell with "after-td-click" event.

The functionality proposed is when user checks/unchecks the checkbox (and not on click of a cell), then we need to select that particular checked row and refresh a graph for that row and for that I need to have an event to handle this scenario, I feel.

I could not find any any such event for the same.

P.S. Don't mind I just gone through the aha-table implementation and found out that if an event after-row-selected (say) is fired in select (data manipulation) function then it will be very helpful.

Thanks for your help in advance...

-- Roy

Need option for row selection

Without having edit enabled, there needs to be an option to have row selection (where the row highlights)..

This would be very useful.

search api on columns

How can you have a separate api to use the search ability on a column from outside the table. So if I have a search box not in the table, and want that input to filter on a column in the table, how can you do this?

Server-side pagination

Hi,

I find aha-table already very useful.

What I am missing is a way to load the next page dynamically.

Sort Integer type data

Hello
Column contains numbers and we want to enable user to sort them as integers.
What is the correct approach is recommended?

Currently they get sorted as string. so breaks for 11, 9, 1 as an example.

HTTP links in table columns

Thanks for a great component :) I was wondering what how you would recommend extending aha-table to allow http links in table columns? When adding a '' in a text column it comes out as pure text as its escaped, which probably makes sense as default behavior. Any hints?

number of results shown per page not updating

when you change the number of results to show when viewing the table it does not update the number shown per page until you view a different page.

so if you have a table with 100 results and you are shown 10 per page, and then you click the option to change it to 50 per page, it still says 1 - 10 / 100 (even though there are now 50 per page) until you click to the 2nd page, and then it fixes itself.

Pretty JSON in table column

Hi.
I'd like to insert JSON data in table column.

ex)
{
"foo": "bar"
}

But this is displayed in a line as below.
{"foo": "bar"}

Is there any option for pretty JSON text in table column?
I mean, I'm wondering if aha-table can contain formatted text such a html pre tag.

datetime examples

What is the proper format that needs to be used for the datetime sort to work? There is currently no example. Or can the time in milliseconds be used on it and hidden and have that used as the sort?

Weird behavior on row checkboxes when selecting/unselecting all - solved for me

I found a weird behavior when checking selectall after having selected some of the rows. When playing a bit aroud I ended up having some selected rows (grey highlight on themed table) without their checkboxes checked and come unselected rows with their boxes checked.

I solved this problem for me by changing
checked?="{{ row._selected }}"/>
with
checked="{{ row._selected }}"/>

on line 226

IE 11 compatibility problem

Hi,

I have problem with IE 11 where are missing data inside table - even demo is not working correctly. I have no problem with Chrome or Firefox. Just guessing - polyfill layer wrongly linked, or? Anybody else with the same problem?

thank you for the answer

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.