Forked from vvelingkar-cci/components.foo-content.template.hbs
Created
January 7, 2019 13:14
-
-
Save kimroen/96fa2a2acfc4eda17e93d7f7f258686b to your computer and use it in GitHub Desktop.
my Demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Component from '@ember/component'; | |
import { observer } from '@ember/object'; | |
import DynamicTable from '../../mixins/ember-light-table-data-mixin'; | |
export default Component.extend(DynamicTable, { | |
sort: '', | |
dir: '', | |
isLoading: true, | |
onDataTableLoad: observer('dataTable', function() { | |
if (this.get('dataTable')) { | |
this.get('model').setObjects(this.get('dataTable').toArray()); | |
this.set('isLoading', false); | |
} | |
}) | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Controller from '@ember/controller'; | |
import { computed } from '@ember/object'; | |
export default Controller.extend({ | |
dir: 'asc', | |
sort: 'orderedAmount', | |
actions: { | |
changeSort({sortProp, sortDir}) { | |
console.log(sortDir, sortProp); | |
}, | |
}, | |
dataChild:[ | |
{orderId: 1, itemCount: 5, itemsCity: 'Mumbai' }, | |
{orderId: 2, itemCount: 1, itemsCity: 'Delhi' }, | |
{orderId: 1, itemCount: 2, itemsCity: 'Kochi' }, | |
{orderId: 3, itemCount: 1, itemsCity: 'Delhi' }, | |
], | |
dataParent: [ | |
{ orderId: 1, orderedAmount: 12.3, orderName: 'My First one' }, | |
{ orderId: 2, orderedAmount: 11.0, orderName: 'My Second one' }, | |
{ orderId: 3, orderedAmount: 16.0, orderName: 'My Third one' }, | |
{ orderId: 4, orderedAmount: 23.2, orderName: 'My Fourth one' }, | |
{ orderId: 5, orderedAmount: 122.5, orderName: 'My Fifth one' }, | |
], | |
columnsParent: computed(function() { | |
return [ | |
{ | |
label: 'OrderId', | |
valuePath: 'orderId', | |
align: 'right' | |
}, | |
{ | |
label: 'Amount', | |
valuePath: 'orderedAmount', | |
align: 'right' | |
}, | |
{ | |
label: 'Order Name', | |
valuePath: 'orderName', | |
align: 'right' | |
} | |
]; | |
}) | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Table from 'ember-light-table'; | |
import { computed } from '@ember/object'; | |
export default Ember.Mixin.create({ | |
page: 0, | |
limit: 10, | |
dir: '', | |
sort: '', | |
isLoading: false, | |
canLoadMore: true, | |
enableSync: true, | |
model: [], | |
meta: null, | |
columns: null, | |
table: null, | |
init(){ | |
this._super(...arguments); | |
let table = new Table(this.get('columns'), this.get('model'), { enableSync: this.get('enableSync') }); | |
let sortColumn = table.get('allColumns').findBy('valuePath', this.get('sort')); | |
// Setup initial sort column | |
if (sortColumn) { | |
sortColumn.set('sorted', true); | |
} | |
this.set('table', table); | |
}, | |
actions: { | |
onColumnClick(column) { | |
} | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.15.1", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js", | |
"ember": "3.4.3", | |
"ember-template-compiler": "3.4.3", | |
"ember-testing": "3.4.3" | |
}, | |
"addons": { | |
"ember-data": "3.4.2", | |
"ember-light-table": "1.13.2" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment