Jump to content
bernhard

RockGrid - powerful, performant and beautiful data listing tool

Recommended Posts

19 minutes ago, jmartsch said:

short note: the name of the module in this file is still RockGrid instead of FieldtypeRockGrid.

thx, I updated the readme and it will be committed in the next version. It now looks like this:

You need to include `moment.js` to your assets. In your field's php file do this:
```php
// eg site/assets/RockGrid/fields/yourfield.php
$this->rg->assets->add($this->config->paths->siteModules . 'FieldtypeRockGrid/lib/moment.min.js');
```

Assets is a property of FieldtypeRockGrid, you are inside the inputfield so there is no assets property.

Does that help?

Share this post


Link to post
Share on other sites

This does not really help, as I have no field for the RockGrid because it is created on the fly in my Dashboard module.

When I created that file "site/assets/RockGrid/fields/yourfield.php", the code to add the moment.js lib works, but now my grid was empty.

My stats.php (thats the name of my InputfieldRockGrid) file looked like this:

$this->rg->assets->add($this->config->paths->siteModules . 'FieldtypeRockGrid/lib/moment.min.js');

I think I then have to also copy the code to setup the RockGrid to this file, right?

However, I found a much simpler way to add the script, via ProcessWire's own method.

So now in my module I have this code, which works:

public function __executeRockGrid()
  {
    $f = $this->modules->get('InputfieldRockGrid');
    $f->name = 'stats';
    $f->themeBorder = 'none';
    $f->height = 0;
    $f->pageSize = 50; // set initial pagination to 25 rows

    $finder = new \ProcessWire\RockFinder('template=stelle', ['title', 'created']);
    $field = $finder->addField('mitarbeiterId', ['vorname', 'nachname']);

    $this->config->scripts->add($this->config->urls->siteModules . "FieldtypeRockGrid/lib/moment.min.js");

    $f->setData($finder);

    return $f->render();
  }

Any complaints doing it this way?

Share this post


Link to post
Share on other sites
6 minutes ago, jmartsch said:

Any complaints doing it this way?

No, absolutely not 🙂 You just have to make sure that it is loaded properly.

I'd recommend you name your field and place everything in a separate related php file to keep everything clean and organized. You'll end up with much nicer processmodules like this one:

JFfUSH4.png

The yourfield.php file can look like this:

<?php namespace ProcessWire;
$this->rg->assets->add($this->config->paths->siteModules . 'FieldtypeRockGrid/lib/moment.min.js');
$this->rg->assets->add($this->config->paths->siteModules . 'FieldtypeRockGrid/lib/currency.min.js');

// your finder here
$finder = ...

// set data
$this->setData($finder);

// send variables to JS
// for example you can send an array of key/value pairs of a select options field
// in the grid you can then replace the options ID that is returned by the finder with the corresponding label
// like that (pseudocode): cellRenderer = function(params) { return grid.js.youroptions[key] }
$this->js([
  'youroptions' => $youroptions,
]);

 

  • Like 1

Share this post


Link to post
Share on other sites

Lots of updates for the weekend 🙂

 

Regarding the filter:

To apply this filter to one of your columns you just need to do this (full example here: https://gitlab.com/baumrock/FieldtypeRockGrid#create-custom-filters):

col = grid.getColDef('title');
col.filter = RockGrid.filters.example;
col.floatingFilterComponent = RockGrid.filters.exampleFloating;

Here is the example filter implementing a "smart search": https://gitlab.com/baumrock/FieldtypeRockGrid/blob/master/plugins/filters/example.js

It looks like this:

XRnkws7.png

Code with removed comments to see that it only 100 lines of code for your very own filter without limits (custom GUI, custom filter logic etc):

Spoiler

/**
 * simple filter
 */
document.addEventListener('RockGridReady', function(e) {

  /**
   * create filter class
   * all methods are mandatory unless they are marked optional
   */
  function filter() {}
  
  filter.prototype.init = function (params) {
    console.log(this);
    this.valueGetter = params.valueGetter;
    this.filterText = null;
    this.params = params;
    this.setupGui();
  };

  filter.prototype.getGui = function () {
    return this.gui;
  };

  filter.prototype.setupGui = function () {
    this.gui = document.createElement('div');
    this.gui.innerHTML =
      '<div style="padding: 4px;">' +
      '<div style="font-weight: bold;">Smart search:</div>' +
      '<div><input style="margin: 4px 0px 4px 0px;" type="text" placeholder="Enter..."/></div>' +
      '<div><em>"jo do" will find "John Doe"</div>' +
      '</div>';
    this.eFilterInput = this.gui.querySelector('input');
    
    var that = this;
    onFilterChanged = RockGrid.debounce(function() {
      that.filterText = that.eFilterInput.value;
      that.params.filterChangedCallback();
    });
    this.eFilterInput.addEventListener("input", onFilterChanged);
  };

  filter.prototype.doesFilterPass = function (params) {var passed = true;
    var valueGetter = this.valueGetter;
    var value = valueGetter(params);
    if(!value) return false;

    this.filterText.toLowerCase().split(" ").forEach(function(filterWord) {
      if (value.toString().toLowerCase().indexOf(filterWord)<0) {
        passed = false;
      }
    });
  
    return passed;
  };

  filter.prototype.isFilterActive = function () {
    return  this.filterText !== null &&
      this.filterText !== undefined &&
      this.filterText !== '';
  };

  filter.prototype.getModel = function () {
    return this.isFilterActive() ? this.eFilterInput.value : null;
  };

  filter.prototype.setModel = function (model) {
    this.eFilterInput.value = model;
    this.filterText = this.eFilterInput.value;
  };

  RockGrid.filters.simple = filter;
});

/**
 * simple floating filter
 */
document.addEventListener('RockGridReady', function(e) {
  function floatingFilter() {}

  floatingFilter.prototype.init = function (params) {
    this.onFloatingFilterChanged = params.onFloatingFilterChanged;
    this.setupGui();
  };
  
  floatingFilter.prototype.getGui = function () {
    return this.gui;
  };

  floatingFilter.prototype.setupGui = function() {
    this.currentValue = null;
    this.gui = document.createElement('div');
    this.gui.innerHTML = '<input placeholder="simple.js" type="text"/>'
    this.eFilterInput = this.gui.querySelector('input');

    var that = this;
    onInputBoxChanged = RockGrid.debounce(function() {
      if (that.eFilterInput.value === '') {
        that.onFloatingFilterChanged(null);
        return;
      }
      
      that.currentValue = that.eFilterInput.value;
      that.onFloatingFilterChanged(that.currentValue);
    });
    this.eFilterInput.addEventListener('input', onInputBoxChanged);
  }

  floatingFilter.prototype.onParentModelChanged = function (parentModel) {
    var value = !parentModel ? '' : parentModel + '';
    this.eFilterInput.value = value;
    this.currentValue = parentModel;
  };

  RockGrid.filters.simpleFloating = floatingFilter;
});

 

  • Like 3

Share this post


Link to post
Share on other sites

Hi @bernhard. I would like to change the styling/rendering of one or more header columns. For example I want to change the background color.

How would I do that? I found this instruction from the aggrid site https://www.ag-grid.com/javascript-grid-header-rendering/ but how would I integrate this into RockGrid?

Or is there an easy way to add a class to a specific header column?

How do I disable a plugin/button? For example the Excel export button?

Somewhere in your code I found

document.addEventListener('RockGridButtons.beforeRender', function (e) {
    // Buttons entfernen
    if (e.target.id != 'RockGridItem_stats') return
    var grid = RockGrid.getGrid(e.target.id)
    var plugin = grid.plugins.buttons

    // remove a btton
    plugin.buttons.remove('refresh')
})

which does not work. The  the listener event is never fired.

Also I  found

document.addEventListener('RockGridItemBeforeInit', function (e) {
    if (e.target.id != 'RockGridItem_stats') return
    var grid = RockGrid.getGrid(e.target.id)

    grid.disablePlugin('excel');
})

which also doesn't work.

 

Share this post


Link to post
Share on other sites

Hi Bernhard,

I am testing RockGrid for the first time now. It looks really great.

I know I could read tfm for hours now, but I dare to ask a few questions:

1. How can I get a link on the row near the id for linking to the page editor? The same way it is done in "RockFinder Tester"? SOLVED

2. How can I deal with the "Select Options" field type, if I don't want to show the id's but the values?

3. How can I change the color of a row, depending on a certain row value?

Thank you.

(Lazy Theo)

Share this post


Link to post
Share on other sites
17 hours ago, theo said:

3. How can I change the color of a row, depending on a certain row value?

 

As https://www.ag-grid.com/javascript-grid-row-styles/#row-class says, you need to modify the gridOptions.rowClassRules for this.

Now I found out how to do this. In your javascript file do this:

document.addEventListener('RockGridItemAfterInit', function (e) {
    if (e.target.id != 'RockGridItem_stats') return
    var grid = RockGrid.getGrid(e.target.id)
    
    // set style of all rows to color #cecece remember styles are bad, better use classes
    grid.gridOptions.rowStyle = {background: '#cecece'};
    // this is untested. First is the class to be assigned and second is the condition
	grid.gridOptions.rowClassRules: {
    'rag-green': 'data.age < 20',
      'rag-amber': 'data.age >= 20 && data.age < 25',
      'rag-red': 'data.age >= 25'
      }
    // you can use the grid api like this:
    // grid.api().sizeColumnsToFit();
    //grid.api().setHeaderHeight(48);
})

 

  • Like 2

Share this post


Link to post
Share on other sites

@jmartsch Thank you! I will try it this evening.

Btw. do you know if something like this (see image below which shows a bootstrap table by wenzhixin) is possible with RockGrid? (with reasonable effort).

I would like to use "Select Options" field types, which show their value instead of the key and which can be filtered with a Select Box (see "Status" in the image below).

Thank you.

selectbs.png

Share this post


Link to post
Share on other sites
19 hours ago, theo said:

I am testing RockGrid for the first time now. It looks really great.

Glad to hear that. I'm also still impressed how powerful and well crafted aggrid is 🙂

19 hours ago, theo said:

1. How can I get a link on the row near the id for linking to the page editor? The same way it is done in "RockFinder Tester"? SOLVED

If others read this just have a look here: https://gitlab.com/baumrock/FieldtypeRockGrid/blob/master/plugins/columns/rgColAddIcons.md

19 hours ago, theo said:

2. How can I deal with the "Select Options" field type, if I don't want to show the id's but the values?

https://gitlab.com/baumrock/FieldtypeRockGrid/blob/master/readme.md#transmit-data-to-the-client-side

19 hours ago, theo said:

3. How can I change the color of a row, depending on a certain row value?

https://www.ag-grid.com/javascript-grid-row-styles/

 

  • Like 1

Share this post


Link to post
Share on other sites
1 hour ago, theo said:

Btw. do you know if something like this (see image below which shows a bootstrap table by wenzhixin) is possible with RockGrid? (with reasonable effort).

I would like to use "Select Options" field types, which show their value instead of the key and which can be filtered with a Select Box (see "Status" in the image below).

This is called "Set Filter" in aggrid and it is an enterprise feature: https://www.ag-grid.com/javascript-grid-filter-set/

YEvDIua.png

 

I've already created two custom filters: https://gitlab.com/baumrock/FieldtypeRockGrid/tree/master/plugins/filters

I want to create a filter similar to the set filter of aggrid one day, but it has low priority at the moment. You can try my smart filter (that is already default in the new versions) or you can try to build your own. If you (or anybody else) are/is interested in sponsoring this type of filter for the community please let me know.

  • Like 2

Share this post


Link to post
Share on other sites

@bernhard Thanks a lot. I will try this tonight.

Yes, "Set filter" is what I would need. This is critical.

Since I don't have enough time for experiments atm., I think I'll go with bootstrap table working on normal MySQL Table this time.

I have everything at hand with this system, it just takes a few changes. So that's my best bet to get the job done as fast as possible.

But I'll come back to RockGrid.

Thank you.

Share this post


Link to post
Share on other sites
5 hours ago, theo said:

I think I'll go with bootstrap table working on normal MySQL Table this time.

I have everything at hand with this system, it just takes a few changes. So that's my best bet to get the job done as fast as possible.

I would be interested how you do that 🙂

Share this post


Link to post
Share on other sites
11 hours ago, bernhard said:

I would be interested how you do that 🙂

I am not sure what you mean. I'm using bootstrap table and some PHP for the database operations.

I can copy most parts from code had written before. I know how it works, so it is easy for me. That's all.

It has nothing to do with Processwire.

P.S. See also

http://issues.wenzhixin.net.cn/bootstrap-table/#extensions/select2-filter.html

http://issues.wenzhixin.net.cn/bootstrap-table/#extensions/editable.html

Share this post


Link to post
Share on other sites

Update: RockGrid is now translateable via the pw backend 🙂 To be more precise: RockGrid has always been multilanguage, just aggrid's labels for Page 1 of X and "loading..." etc. where not translateable until now.

xnoPWp7.png

9zDB1Lb.png

The translation file is attached to the first post of this thread:

 

  • Like 4

Share this post


Link to post
Share on other sites

@bernhard You should update ag grid to the latest version, as it brings numerous good improvements. See https://www.ag-grid.com/ag-grid-changelog/?fixVersion=18.0.0 and https://www.ag-grid.com/ag-grid-changelog/?fixVersion=19.0.0

I made a quick test with the new version and everything works well in my case.

The name of the script has been changed to ag-grid-community.js

  • Thanks 1

Share this post


Link to post
Share on other sites
2 hours ago, jmartsch said:

@bernhard You should update ag grid to the latest version, as it brings numerous good improvements. See https://www.ag-grid.com/ag-grid-changelog/?fixVersion=18.0.0 and https://www.ag-grid.com/ag-grid-changelog/?fixVersion=19.0.0

I made a quick test with the new version and everything works well in my case.

Can confirm everything works. I updated ag-grid soon after I started tinkering with RockGrid.

  • Thanks 1

Share this post


Link to post
Share on other sites

I also get it on Firefox. Which version did you try exactly? the single-js version or the one with separate css?

I also tried it with Reno + Uikit... no difference

Share this post


Link to post
Share on other sites

Please take a look about the new autoheight setting https://www.ag-grid.com/javascript-grid-width-and-height/#auto-height

Here is an example where you can switch between a fixed height and autoheight:

Example

With autoheight enabled the vertical scrollbar appears, which might be a small bug in ag grid, but it doesn't bother me.

 

  • Like 1

Share this post


Link to post
Share on other sites

ok thx just pushed v0.0.12 including aggrid v19.0.0

seems that the scrollbar thing is an issue with aggrid itself and has nothing to do with any of my modules so i'm fine with it. grids can be tricky and i guess they have a good reason why they changed to flex and why the scrollbar is there (i guess it makes other things a lot easier/better).

@Beluga I would be interested in how you are using RockGrid and what you think of it so far 🙂

PS: Just added the module to the modules directory.

  • Like 1

Share this post


Link to post
Share on other sites
5 minutes ago, bernhard said:

@Beluga I would be interested in how you are using RockGrid and what you think of it so far 🙂

The plan is to have it as an interface to filter from two collections of proverbs, international with 35k items and Finnish with 8k. Filtering would target the proverb text. The db includes thematic categorisation, book references, cross-references for culture/language and various research-related tidbits. There will be other views on the material without the grid (like a digital card per proverb etc.).

I like RockGrid very much and the new smart filter is a really nice addition. I will look into paying you after we launch the site.

  • Like 2

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Mike Rockett
      Jumplinks for ProcessWire
      Release: 1.5.56
      Composer: rockett/jumplinks
      Jumplinks is an enhanced version of the original ProcessRedirects by Antti Peisa.
      The Process module manages your permanent and temporary redirects (we'll call these "jumplinks" from now on, unless in reference to redirects from another module), useful for when you're migrating over to ProcessWire from another system/platform. Each jumplink supports wildcards, shortening the time needed to create them.
      Unlike similar modules for other platforms, wildcards in Jumplinks are much easier to work with, as Regular Expressions are not fully exposed. Instead, parameters wrapped in curly braces are used - these are described in the documentation.
      Under Development: 2.0, to be powered by FastRoute
      As of version 1.5.0, Jumplinks requires at least ProcessWire 2.6.1 to run.
      View on GitLab
      Download via the Modules Directory
      Read the docs
      Features
      The most prominent features include:
      Basic jumplinks (from one fixed route to another) Parameter-based wildcards with "Smart" equivalents Mapping Collections (for converting ID-based routes to their named-equivalents without the need to create multiple jumplinks) Destination Selectors (for finding and redirecting to pages containing legacy location information) Timed Activation (activate and/or deactivate jumplinks at specific times) 404-Monitor (for creating jumplinks based on 404 hits) Additionally, the following features may come in handy:
      Stale jumplink management Legacy domain support for slow migrations An importer (from CSV or ProcessRedirects) Feedback & Feature Requests
      I’d love to know what you think of this module. Please provide some feedback on the module as a whole, or even regarding smaller things that make it whole. Also, please feel free to submit feature requests and their use-cases.
      Note: Features requested so far have been added to the to-do list, and will be added to 2.0, and not the current dev/master branches.
      Open Source

      Jumplinks is an open-source project, and is free to use. In fact, Jumplinks will always be open-source, and will always remain free to use. Forever. If you would like to support the development of Jumplinks, please consider making a small donation via PayPal.
      Enjoy! :)
    • By BitPoet
      As threatened in Ryan's announcement for 3.0.139, I built a little module for sliding toggles as a replacement for checkboxes. Styling of the input is CSS3 only (with all the usual caveats about older browsers), no JS necessary, and may still be a bit "rough around the edges", so to speak, since I didn't have much time for testing on different devices or brushing things up enough so I'd feel comfortable pushing it to the module directory. But here's the link to the GitHub repo for now:
      InputfieldSlideToggle
      Fieldtype and Inputfield that implements smartphone-style toggles as replacement for checkbox inputs. The visualization is CSS-only, no additional JS necessary.
      Status
      Still very alpha, use with caution!
      Features / Field Settings
      Size
      You can render the toggles in four different sizes: small, medium, large and extra large.
      Off Color
      Currently, "unchecked" toggles can be displayed either in grey (default) or red.
      On Color
      "Checked" toggles can be rendered in one of these colors: blue (default), black, green, grey, orange or red.
      Screenshots

      Some examples with checkbox label


      View all Size and Color Combinations
      Small toggles Medium toggles Big toggles Extra big toggles  









    • By Orkun
      Hi Guys
      I needed to add extended functionalities for the InputfieldDatetime Module (module is from processwire version 2.7.3) because of a Request of Customer.
      So I duplicated the module and placed it under /site/modules/.
      I have added 3 new Settings to the InputfieldDatetime Module.
      1. Day Restriction - Restrict different days based on weekdays selection (e.g. saturday, sunday) - WORKING

       
      2. Time Slots - Define Time slots based on custom Integer Value (max is 60 for 1 hour) - WORKING

       
      3. Time Range Rules per Weekday - Define a minTime and MaxTime per Weekday (e.g. Opening Hours of a Restaurant) - NOT WORKING PROPERLY

       
      The Problem
      Time Slots and Day Restriction working fine so far. But the Time Range Rules per Weekday doesn't work right.
      What should happen is, that when you click on a date, it should update the minTime and maxTime of the Time Select.
      But the change on the select only happens if you select a date 2 times or when you select a date 1 time and then close the datepicker and reopen it again.
      The time select doesn't get change when you select a date 1 time and don't close the picker.
      Here is the whole extended InputfieldDatetime Module.
      The Files that I have changed:
      InputfieldDatetime.module InputfieldDatetime.js jquery-ui-timepicker-addon.js (https://trentrichardson.com/examples/timepicker/) - updated it to the newest version, because minTime and maxTime Option was only available in the new version  
      Thats the Part of the JS that is not working correctly:
      if(datetimerules && datetimerules.length){ options.onSelect = function(date, inst) { var day = $(this).datetimepicker("getDate").getDay(); day = day.toString(); var mintime = $(this).attr('data-weekday'+day+'-mintime'); var maxtime = $(this).attr('data-weekday'+day+'-maxtime'); console.log("weekday: "+day); console.log("minTime: "+mintime); console.log("maxTime: "+maxtime); var optionsAll = $(this).datetimepicker( "option", "all" ); optionsAll.minTime = mintime; optionsAll.maxTime = maxtime; $(this).datetimepicker('destroy'); $(this).datetimepicker(optionsAll); $(this).datetimepicker('refresh'); //$.datepicker._selectDate($(this).attr("id"),date); //$.datepicker._base_getDateDatepicker(); // var inst = $.datepicker._getInst($(this)); // $.datepicker._updateDatepicker(inst); /*$(this).datetimepicker('destroy'); InputfieldDatetimeDatepicker($(this), mintime, maxtime); $(this).datetimepicker('refresh'); */ // $(this).datetimepicker('option', {minTime: mintime, maxTime: maxtime}); } } Can you have a look and find out what the Problem is?
      InputfieldDatetime.zip
       
      Kind Regards
      Orkun
    • By teppo
      This module tracks changes, additions, removals etc. of public (as in "not under admin") pages of your site. Like it's name says, it doesn't attempt to be a version control system or anything like that - just a log of what's happened.
      At the moment it's still a work in progress and will most likely be a victim of many ruthless this-won't-work-let's-try-that-instead cycles, but I believe I've nailed basic functionality well enough to post it here.. so, once again, I'll be happy to hear any comments you folks can provide
      https://modules.processwire.com/modules/process-changelog/
      https://github.com/teppokoivula/ProcessChangelog
      How does it work?
      Exactly like it's (sort of) predecessor, Process Changelog actually consists of two modules: Process Changelog and Process Changelog Hooks. Hooks module exists only to serve main module by hooking into various functions within Pages class, collecting data of performed operations, refining it and keeping up a log of events in it's own custom database table (process_changelog.) Visible part is managed by Process Changelog, which provides users a (relatively) pretty view of the contents of said log table.
      How do you use it?
      When installed this module adds new page called Changelog under Admin > Setup which provides you with a table view of collected data and basic filtering tools See attached screenshots to get a general idea about what that page should look like after a while.
      For detailed installation instructions etc. see README.md.
       


    • By Gadgetto
      Status update links (inside this thread) for SnipWire development will be always posted here:
      2019-08-08
      2019-06-15
      2019-06-02
      2019-05-25
      If you are interested, you can test the current state of development:
      https://github.com/gadgetto/SnipWire
      Please note that the software is not yet intended for use in a production system (alpha version).
      If you like, you can also submit feature requests and suggestions for improvement. I also accept pull requests.
      ---- INITIAL POST FROM 2019-05-25 ----
      I wanted to let you know that I am currently working on a new ProcessWire module that fully integrates the Snipcart Shopping Cart System into ProcessWire. (this is a customer project, so I had to postpone the development of my other module GroupMailer).
      The new module SnipWire offers full integration of the Snipcart Shopping Cart System into ProcessWire.
      Here are some highlights:
      simple setup with (optional) pre-installed templates, product fields, sample products (quasi a complete shop system to get started immediately) store dashboard with all data from the snipcart system (no change to the snipcart dashboard itself required) Integrated REST API for controlling and querying snipcart data webhooks to trigger events from Snipcart (new order, new customer, etc.) multi currency support self-defined/configurable tax rates etc. Development is already well advanced and I plan to release the module in the next 2-3 months.
      I'm not sure yet if this will be a "Pro" module or if it will be made available for free.
      I would be grateful for suggestions and hints!
      (please have a look at the screenshots to get an idea what I'm talking about)
       




×
×
  • Create New...