GO Grid

go.grid

Angular directive - turning data into scrollable, filterable, sortable data grid

After taking so much from open source community I decided to give something from me

Example

Sample data with 100 rows
  • Filtering

    Input field translated to regexp
    Usage:

    • word1|word2 - finds row containing word1 or word2
    • word1&word2 - finds row containing word1 and word2 as well
    • JS Regular expression should work fine

  • Sorting
  • Column reordering (not working at this time as it needs moveUp/moveDown methods on Array.protoype)
  • Column visibilitiy toggle
{{ item.id }} {{ item.field1 }} {{ item.field2 }} {{item.field6}}
HTML
JS

          
            <div go-grid data-source="items" infinite on-select="select()" name="demo">
            

<filters>
<search-filter fields="field1,field2,field3,field4,field5,field6,field7,field9" name="query"></search-filter>
</filters>

<columns>
<checkbox-column width="40" field="selected"></checkbox-column>
<column width="40" name="id" header="ID" sort resize right>
<a ng-href="#/{{item.id}}" class="office-thumbail">{{ item.id }}</a>
</column>
<column width="120" name="field1" header="Field 1" sort resize>
<strong>{{ item.field1 }} {{ item.field2 }}</strong>
</column>
<column width="120" name="field2" header="Field 2" sort resize>
<span class="label label-info">{{item.field6}}</span>
</column>
<column width="120" name="field3" header="Field 3" sort resize></column>
<column width="120" name="field4" header="Field 4" sort resize></column>
<column width="120" name="field5" header="Field 5" sort resize></column>
<column width="120" name="field6" header="Field 6" sort resize></column>
<column width="120" name="field9" header="Field 7" sort resize right></column>
<column width="120" name="field7" header="Field 8" sort resize></column>
<column width="120" name="field12" header="Field 11" sort resize></column>

</columns>
</div>
          angular.module('sampleApp', ['go.grid'])
          
.controller('SampleController', ['$scope', function ($scope) {
// angular.module('go.grid').locale = 'pl'
$scope.select = function(item) {
for(var i = 0; i < $scope.items.length; i++) {
delete $scope.items[i].active
if( $scope.items[i] === item) {
item.active = true
}
}
}

$scope.items = [
];
var string = 'Ut a ipsum in justo varius pulvinar vitae non orci. Donec luctus ipsum eget ante dictum, sit amet tempus dolor tempus. Nunc eu condimentum elit. Sed placerat, nisl eget lacinia commodo, enim massa congue sem, non fringilla lorem tellus euismod nibh. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent ut erat aliquam, efficitur urna sed, volutpat libero. Mauris non eleifend ex. Vivamus condimentum leo augue, eu finibus ligula luctus vel. Phasellus a odio non purus vehicula laoreet et in dui. Ut maximus venenatis neque eu venenatis. In blandit tellus et orci pharetra, eu tincidunt dolor pellentesque. Cras in elit ut nibh egestas dictum eget eget dui. Nullam porttitor, tellus eu bibendum sodales, nulla ante semper mi, quis molestie nunc augue sed quam. Pellentesque leo nisi, laoreet ac tortor in, sagittis molestie eros. Morbi velit augue, posuere quis neque vitae, condimentum consequat magna.'.split(' ');

var l = string.length - 1;

for (var i = 1; i <= 100; i++) {

i1 = Math.round(Math.random() * l)
i2 = Math.round(Math.random() * l)
i3 = Math.round(Math.random() * l)
i4 = Math.round(Math.random() * l)
i5 = Math.round(Math.random() * l)
i6 = Math.round(Math.random() * l)
i7 = Math.round(Math.random() * l)
i8 = Math.round(Math.random() * l)
i9 = Math.round(Math.random() * 100000) / 100
$scope.items.push({
id: i,
field1: string[i1],
field2: string[i2],
field3: string[i3],
field4: string[i4],
field5: string[i5],
field6: string[i6],
field7: string[i7],
field9: i9,
})


}

}]);

TODO

  • Include required libraries in single js file (concat). Including everything is pain ....
  • Make column reordering work
  • Many many things that I don't know or have no time :)