Category Archives: Web Tools

Datatable with Row Details (Child Row)

Example:

https://datatables.net/examples/api/row_details.html

Data Format (with column name)

https://datatables.net/examples/ajax/data/objects.txt

Columns Config:

https://datatables.net/reference/option/columns

JS example:

 

Redis Commands

Reference:

http://redisdoc.com/list/lrange.html

Command Description
LPUSH key value [value …] 将一个或多个值 value 插入到列表 key 的表头

redis> LPUSH mylist a b c
(integer) 3

redis> LRANGE mylist 0 -1
1) “c”
2) “b”
3) “a”

LRANGE key start stop  返回列表 key 中指定区间内的元素,区间以偏移量 start 和 stop 指定。

LRANGE mylist 0 -1
取得mylist第一個到最後一個的元素

Reference:

Tinymce config for Laravel File Manager

 

Customize tinymce in Voyager

Add additional_js:

https://docs.laravelvoyager.com/customization/additional-css-js

‘js/custom.js’ => ‘public/js/custom.js’

Add callback function in additional js:

https://docs.laravelvoyager.com/customization/tinymce

Rename or copy plugin.min.js to plugin.js

TinyMCE will find plugin.js of each plugins in public\vendor\tcg\voyager\assets\js\plugins
https://www.tiny.cloud/docs/advanced/creating-a-plugin/

Example:

 

Reference:

  1. https://github.com/the-control-group/voyager/issues/1945
  2. Remove doctype and html tags that generated by tinymce automatically: Remove fullpage plugin.
    https://stackoverflow.com/questions/17829239/how-can-i-stop-tinymce-from-adding-doctype-htmlhtmlhead-headbody-to-e
  3. https://stackoverflow.com/questions/6266487/tinymce-allow-all-html-tag
  4. https://stackoverflow.com/questions/7744903/tinymce-allow-data-attribute

Show custom error messages from server side

The key is to add a listener to “xhr.dt” event before initialize datatable plugin.

Server side:

 

Reference:

  1. https://datatables.net/reference/event/xhr

Custom http error response in JSON

Server side (PHP):

Client (with datatable):

Result in Chrome dev tool: