News in version
TreeGrid Gantt chart SpreadSheet Examples Documentation Download Development Licensing Prices References Contacts Buy Try it free
Documentation
Search in documentation
TreeGrid versions compatibility

Changes log (txt file) Using custom CSS from 13.3 to 14.0 Upgrading from 9.3 to 10.0 Upgrading from 5.9 to 6.0

Using in JavaScript frameworks

Angular React Vue Other frameworks NodeJS server

Creating grid

Simple examples Basic information Creating grid Deleting grid Reloading grid Rendering grid Accessing grid by API

Data & communication
Data communication with server

Communication types AJAX communication AJAX SOAP envelope Submit communication Directly included data Data from JavaScript Cross domain / local load by JSONP Sessions (AJAX) Server response (AJAX) Synchronous communication (AJAX) Caching (AJAX) API (AJAX)

Download data

Settings for data download Layout XML structure Data XML structure

Upload data

Settings for data upload API for upload XML structure sent to server

Changing data from server

XML structure of download changes XML structure of request for a cell Synchronizing data with server

Input / output data formats

Complete list of tags Internal XML format Short XML format Extra short XML format DTD XML format JSON format

Cells
Cell basics

Cell type Cell format Dynamic format Dynamic type Cell value Reading / writing attributes by API Cell HTML Cell default Range or more values in one cell Cell with link URL Cell hint Cell tooltip / title Cell popup menu

Cell editing and changing values

Cell editability Dynamic editing Locking Defaults list Suggest list (auto complete) Changing cell value Mass cell change Clearing cells Editing cells Controlling <input> tag by JavaScript Input validation and restrictions Side checkbox Cell selecting

Calculations - cell formulas

Basics Formulas Mathematical functions Aggregate functions Special functions for actions Custom functions

Calculations - editable cell formulas

Basics Suggest list (auto complete) Defined names Actions for choosing cells Conditional functions Lookup functions Cell reference functions Logical functions Informational functions Mathematical functions Trigonometry functions Rounding numbers Number conversions String functions Date functions Summary functions Custom functions

Cell side buttons

Introduction Right side Button Left side Icon

Cell spanning

Column span Row span Dynamic spanning

Cell style and color

Basic grid style Sizing and scaling - responsive design Dynamic cell style attributes Cell CSS class Cell background color Dynamic cell border Cell HTML style Row color alteration Cell mouse cursor

Editable cell images

Insert image Edit image

Cell types
Automatic type - Auto String - Text, Lines & Pass
Number - Int & Float

Format Localization

Date and time - Date

Format Calendar component Dates dialog Localization

List & combo - Enum & Radio

Introduction Definition Related lists Enum specific Radio specific

Checkbox - Bool
Action button - Button

Introduction Basic clickable button Switch button Radio / tab button Menu button Combo switch button Combo radio / tab button Special Space rows with buttons

Panel with more buttons - Panel

Definition Standard fast panel Custom panel

HTML and special types

Html type EHtml type (editable) Icon type Abs type List type Editable Link type Editable Img type DropCols type Upload File type

Columns

Column basics Column index Column visibility Column visibility menu Column selecting Column tree Auto column tree Column position and moving Column adding and copying Column deleting Column width Column API

Rows
Row basics

Rows by functionality Rows by position Row name Row id Row index

Default rows

Description Example of default rows Example of changing default row Attributes

Row tree

Tree attributes Actions & API for expand / collapse

Row identification

Setting row id attribute Row id attribute in tree Row id created from cell values API for row ids

Row visibility
Row adding and copying

Five ways of adding rows to grid Adding and copying restrictions Adding new empty rows Copying existing rows

Row deleting Row moving and dragging Row selecting Row height Row API Space rows
Features
Sorting rows

Sort settings Controlling sort position Comparing strings Sorting actions Sorting API

Grouping rows to tree

Group settings Creating groups Comparing strings Created group rows <D Group='1'/> User interface to choose grouping Grouping actions and API

Filtering rows

Filter settings Comparing strings User interface to choose filter Filter actions and API

Searching in rows and cells

Search settings User interface for search Search actions and API

Printing grid

Print settings Choosing items to print Page size Print API

Print / export to PDF

Introduction Client side settings Printing options Client side API Server side API Data sent from client to server

Export to Excel or CSV

Introduction and export types Basic settings Styling export XLSX export CSV export Old XLS / XHTML export Export API Communication with server Client export Server export

Import from Excel

Basic settings Sheets manipulation

Copy & paste rows via clipboard

Copy & paste permissions Copying to clipboard Pasting from clipboard

Master - detail grids

Introduction External master - detail grids Nested master - detail grids Synchronizing grids Other attributes for master - detail

Pivot tables

Pivot attributes & API Pivot formulas

External objects (like Adobe Flash) Undo & Redo
Gantt and bar chart
Gantt objects

Gantt objects list Display settings Edit settings

Main bar

Definition of main bar and plans Main bar as Task Edit settings Main bar content and side html Tip on mouse hover Vertical position and height Style specific attributes API to manipulate Main bars Actions Side text (deprecated) Real Flow (deprecated)

Run bar

GanttRun Definition Extended definition Run bar as Task Edit settings Save format Selecting Run boxes Run box content and side html Tip on mouse hover Box identification Vertical position and height Style specific attributes Overlaid (Error) boxes Containers for more boxes Dragging - moving and resizing API to manipulate Run boxes Actions Run special formulas

Summary task

Main for Main Main for Run Editable Main Editable Run

Gantt icons - Flag & Point

Flag - icon with text Point - math points

Gantt display objects

Header - column captions Cell and column Background Vertical movable Line Mark & Progress line

Gantt zoom

Zoom options Chart size limits Zoom selection Paging in Gantt chart

Dependency, constraints & schedule

Introduction Data units Defining dependencies Dependency colors and shapes Changing dependencies Correcting dependencies Scheduling algorithm Project date constraints Task date constraints Critical path - Slack (Float)

Gantt calendars

Global base calendar Local calendar Calendar list Calendars dialog Other settings

Gantt resources

Resources list Resources assign Resources filter Resources calculations Availability chart Resource usage chart Generated resource usage chart

Gantt popup menu Gantt API
Line and XY points charts

Charts in grid cells Chart JSON definition Base chart settings Basic attributes Size Axis and caption Individual chart lines Data sources Visual settings API for standalone usage

Paging in large grids
Paging root rows

Paging types and attributes Auto adding root pages API for paging

Pager components

Side pager Side pager type Pages Side pager type Gantt Side pager type Custom Pager with navigation buttons & edit Pager as list of page indexes

Paging in tree

ChildPaging - load / render on expand MaxChildren - limit children count ChildParts - load / render on scroll

Paging columns

Paging types and attributes Auto adding column pages API for column paging

Server paging

Server paging for root rows Server communication in root paging Root paging in very large tables Server paging in tree Server communication in tree paging XML Request for Data in root paging XML Download Data in root paging XML Request for root Page / children XML Download root Page / children API for server paging

TreeGrid DLL/SO for server paging

Introduction Compatibility with TreeGrid control Using TreeGrid server DLL/SO ASP.NET C# ASP.NET VB PHP JSP Java TreeGrid server concepts Function reference Calculations

JSON menus and dialogs
JSON menu description JSON menu definition example
Menu settings

Base attributes Visual settings Key navigation Behavior Size and scroll

Menu item settings

Base attributes Clickable item Inactive caption Collapsible sub level Popup sub menu Columns Bool item Enum item Edit item

Custom menu in JavaScript

Show custom menu Custom menu position Custom menu advanced settings Custom menu JavaScript events Custom menu JavaScript methods

Calendar dialog Custom calendar & JavaScript events Custom dialog in JavaScript
Global grid settings
Grid size and scroll

Default behavior Maximize grid height and width Update size according to the content Let a user to control the grid size Widths of individual sections Other scrolling attributes and API

Media rules - responsive design
Languages

Language & regional setup (Text.xml) Translate texts dynamically Change language

Grid cursor - Focus & hover

Focused cell and row Focused cell range Move and copy focused cells Filling cell values by dragging Tabulator navigation Key navigation Cursor look - focus & hover

Selecting rows, cells and columns

Selecting base Selecting rows Selecting cells Selecting columns

Global settings

Status messages Configuration menus Configuration menu - options Configuration menu - columns Configuration menu - print / PDF Configuration menu - export Default toolbar Useful API function Help file

Animations

Animations base Row animations Column animations Cell animations Animations for undo / redo Animations for server side changes Dialog animations

Grid configuration in cookies
Mouse & key events & actions

List of event handler types TreeGrid mouse events Mouse event names Key and mouse button prefixes Touch event names Event targets Assigning event actions / callbacks Event action parameters Action name suffix Calling actions from JavaScript Creating custom actions Focused vs. Actual cell TreeGrid key events JavaScript API events

Mouse API event TreeGrid files
Debugging and testing

Debug window Automated testing

Editable cell images

TreeGrid documentation

Insert image

Since 15.0 the image files can be inserted directly to the cell values in types EHtml, Auto, Img and Icon and also to grid as floating image in Img attribute.
Not available in Internet Explorer 9 and older!
new 15.0 <Cfg> <C> <I> <cell> string[]

InsertImg

["drop,open,text,float,more"]
If and how can be images inserted to grid in Img attribute and into text in types EHtml, Auto, Img and Icon.
The images are inserted into the cells as data urls and can be uploaded to server.
Comma separated list of flags:
drop - If set, images can be dropped to the cell.
open - If set, images can be placed to the cell by choosing the image(s) from file dialog.
text - If set, images can be inserted into text in edited cell, into cursor position, the image will be a part of the text. Only for EHtml and Auto types.
add - If set, images can be inserted into text in not edited cell, to the end of the text, the image will be a part of the text. Only for EHtml and Auto types.
replace - If set, images can be inserted into text in not edited cell, the image replaces the current content, the image will be a part of the text.
float - If set, images can be inserted to cell, the image will be inserted into Img attribute and will be floating behind text.
readonly - If set, the add and replace flags are applicable also for not editable cells.
more - If set, more images can be chosen in the file dialog and inserted to the cell. Only for EHtml and Auto types.
rowspan - If set, the cell is spanned vertically to other rows to show the text image without changing the row height.
colspan - If set, the cell is spanned horizontally to other columns to show the text image fully.
new 15.0 <Cfg> int

InsertImgMaxWidth

[300]
Maximal width of the inserted image in pixels. The image can be more resized when editing.
new 15.0 <Cfg> int

InsertImgMaxHeight

[200]
Maximal height of the inserted image in pixels. The image can be more resized when editing.
new 15.0 API event bool

OnOpenImage

(TGrid grid, TRow row, string col, img[] images, bool drop, int action)
Called after image(s) is opened or dropped to cell, but before the cell value is modified.
images is array of DOM IMG elements to be added to the cell value. If the cell is type Img or Icon, only the first image will be added to the cell.
The IMG elements are added to the EHtml and Auto type cell as outerHTML, to the Img and Icon cell types only as src attribute value.
drop is set, if the image was dropped to cell. It is not set, if the image was opened by system file dialog.
action is planned action, 1 - add floating image(s) to Img attribute, 2 add image(s) to the cell value, 3 set (replace) image(s) to the cell value.
Return new action or 0 to cancel the action.
new 15.0 <Actions>

OpenImage ...FSAO

Assigned to event OnClickButtonAddImg
Displays system dialog to open local image file and insert it to the actual or focused cell of type EHtml, Auto, Img and Icon or as floating image into Img attribute.
The way of inserting is chosen by InsertImg.
The images are inserted into the cells or to Img attribute as data urls and can be uploaded to server.
new 15.0 <Cfg> bool

DropFiles

[1]
If files can be dropped to the grid.
If set, dropping of any unsupported file to the grid will cancel default browser action for this file drop.
It must be set to permit dropping xlsx files for import, image files to EHtml, Auto, Img and Icon types and to Img attribute and other files to File type.
new 15.0 API event bool

OnDropFile

(TGrid grid, TRow row, string col, file[] files)
Called when a user dropped any file to grid, to given cell. The row and col can be also null.
files is list of the dropped files as dataTransfer.files.
new 15.0 API event bool

OnDropFileError

(TGrid grid, TRow row, string col, file[] files)
Called when a user dropped any file to grid, to given cell and the file was not processed by TreeGrid.
files is list of the dropped files as dataTransfer.files.

Edit image

Since 15.0 the image files can be edited inside cell in types EHtml and Auto and as floating images set by Img attribute.
Not available in Internet Explorer 9 and older!
new 15.0 <cell> string[*]

Img

Floating images assigned to the cell. The images are not related to the cell value, their position is just fixed to the cell.
The floating images are moved with the cell row and column. They are deleted if the cell row or column is deleted. They are not copied with the cell or row or column.
First character separated array as url1,parameters1,url2,parameters2,....
The url is usually data url containing the image data, but can be also standard reference to external image.
The parameters are comma separated values as x,y,width,height,rotate,opacity,name,cx,cy,cwidth,cheight.
x, y is position relative to the cell top left corner, in pixels. They can be relative to bottom right corner if start by "(", e.g. "(10,(20" or to center if start by "!", e.g. "!10,!20".
width, height is final image size in pixels.
rotate is image rotation clockwise in degrees.
opacity is image opacity from 0 as fully transparent to 1 fully opaque.
name is image name, shown as tooltip on mouse hover, need not be unique.
cx, cy is left top corner inside image to crop the image from this position. If set, the x and y is position of the cropped top left corner.
cwidth, cheight is width and height of the crop area in the image. The width and height is always size of the whole image.
For example "|data:Image/png;base64,JsdfSDFDSFLKasdh....|0,0,100,50,90|Test.svg|10,10,50,40,0,0.4,test".
The Img is also uploaded to server with cell and exported to xlsx.
new 15.0 <Cfg> string[]

EditImg

["Move,Shift,Resize,Rotate,Delete,Copy,Assign,Opacity,Float,Name"]
If and how can be edited floating images defined by Img attribute. Comma separated list of case insensitive flags:
Move - If set, floating images can be moved by mouse dragging.
Shift - If set, text images can be moved inside cell by mouse dragging.
Resize - If set, images can be resized by mouse dragging.
ResizeRatio - If set instead of Resize, images can be resized by mouse dragging, but only actions preserving aspect ratio.
Rotate - If set, images can be rotated by mouse dragging.
Delete - If set, floating images can be deleted by DeleteImage action. Text images can be deleted always.
Copy - If set, images can be copied by CopyImage and DuplicateImage and action.
Crop - If set, floating images can be cropped by mouse dragging.
Assign - If set, automatically moves the floating image to another cell after moved, resized or rotated to be the cell always top left corner.
Opacity - If set, permits changing image opacity by EnterImageOpacity action.
Float - If set, permits changing image from floating to text and vice versa.
Name - If set, permits changing image name by action EnterImageName.
new 15.0 <Cfg> string[]

AssignImg

["Left,Top"]
By which corner or center the floating images will be assigned to the cell, two keywords, case insensitive.
Left or Center or Right - horizontal assignment.
Top or Middle or Bottom - vertical assignment.
The image is moved, copied and deleted with the assigned cell.
new 15.0 <Cfg> string[]

DragImg

[...]
An action done when dragging text image edited in EHtml / Auto type cell and floating image in Img attribute. Case insensitive.
Can contain more actions comma separated, it is used the first one permitted by EditImg.
The available actions:
Move - move the floating image,
MoveXY - move the floating image in one direction,
Copy - copy the floating image and move it,
CopyXY - copy the floating image and move it in one direction,
Shift - move the text image inside cell,
Resize - resize the image width and height, preserve aspect ratio,
ResizeXY - resize the image width or height,
ResizeFree - resize the image width and height, ignore aspect ratio,
Rotate - rotate the image 0 - 360 degrees.
Crop - crop the floating image from the nearest direction to the mouse cursor. Text images cannot be cropped.
There are also attributes with suffix for every combination of control keys and mouse buttons in this order: Shift,Ctrl,Alt,Meta,Left,Middle,Right. For example DragImgCtrlRight will be read if dragged by right mouse button and pressed Ctrl.
Default values are: DragImg="Move,Shift,Resize,Rotate" DragImgCtrl="Copy,Shift" DragImgCtrlRight="Rotate" DragImgShift="Resize" DragImgShiftRight="Crop".
new 15.0 <Cfg> int

DragImgMinWidth

[5]
Minimal width of image when resizing or cropping it.
new 15.0 <Cfg> int

DragImgMinHeight

[5]
Minimal height of image when resizing or cropping it.
new 15.0 <C> <cell> int

TextImg

[0]
Controls text images in EHtml and Auto types, bit array.
1. bit &1 - If set, images are restricted in the cell when editing.
2. bit &2 - If set, only images are permitted in the cell when editing.
3. bit &4 - If set, the high image can be cut, if not set, images control text height, higher images increase line height.
new 15.0 <Actions>

DragImage

Assigned to OnDragImg event, can be assigned only to On...DragImg events
Moves, copies, resizes or rotates actual floating image under mouse cursor.
The action is chosen according to the DragImg setting or by action chosen by DragImage... action.
new 15.0 <Actions>

MoveImage

Not assigned to any event, can be assigned only to On...DragImg events
Moves actual floating image under mouse cursor.
new 15.0 <Actions>

MoveXYImage

Not assigned to any event, can be assigned only to On...DragImg events
Moves actual floating image under mouse cursor, only in one direction.
new 15.0 <Actions>

CopyImage

Not assigned to any event, can be assigned only to On...DragImg events
Copies and moves the copy of the actual floating image under mouse cursor.
new 15.0 <Actions>

CopyXYImage

Not assigned to any event, can be assigned only to On...DragImg events
Copies and moves the copy of the actual floating image under mouse cursor. Moves only in one direction.
new 15.0 <Actions>

ResizeImage

Not assigned to any event, can be assigned only to On...DragImg events
Resizes actual floating image under mouse cursor. Preserves aspect ratio.
new 15.0 <Actions>

ResizeXYImage

Not assigned to any event, can be assigned only to On...DragImg events
Resizes actual floating image under mouse cursor. Resize only width or height. Does not preserve aspect ratio.
new 15.0 <Actions>

ResizeFreeImage

Not assigned to any event, can be assigned only to On...DragImg events
Resizes actual floating image under mouse cursor. Does not preserve aspect ratio.
new 15.0 <Actions>

RotateImage

Not assigned to any event, can be assigned only to On...DragImg events
Rotates actual floating image under mouse cursor.
new 15.0 <Actions>

CropImage

Not assigned to any event, can be assigned only to On...DragImg events
Crops actual floating image from the nearest edge to the mouse cursor.
new 15.0 <Actions>

DragImageResize

Not assigned to any event
Sets default dragging action of selected image in edited EHtml / Auto type cell and floating image in Img attribute to "Resize".
If image is dragged without any control button, it is resized, preserves aspect ratio.
new 15.0 <Actions>

DragImageResizeXY

Not assigned to any event
Sets default dragging action of selected image in edited EHtml / Auto type cell and floating image in Img attribute to "ResizeXY".
If image is dragged without any control button, it is resized in one direction.
new 15.0 <Actions>

DragImageResizeFree

Not assigned to any event
Sets default dragging action of selected image in edited EHtml / Auto type cell and floating image in Img attribute to "ResizeFree".
If image is dragged without any control button, it is resized, ignores aspect ratio.
new 15.0 <Actions>

DragImageRotate

Not assigned to any event
Sets default dragging action of selected image in edited EHtml / Auto type cell and floating image in Img attribute to "Rotate".
If image is dragged without any control button, it is rotated.
new 15.0 <Actions>

DragImageCrop

Not assigned to any event
Sets default dragging action of floating image in Img attribute to "Crop".
If image is dragged without any control button, it is cropped from the nearest edge to the mouse cursor.
Text images cannot be cropped.
new 15.0 <Actions>

DragImageMove

Not assigned to any event
Sets default dragging action of selected image in edited EHtml/Auto type cell to "Shift" and floating image in Img attribute to "Move".
If image is dragged without any control button, it is moved.
new 15.0 <Actions>

DragImageMove

Not assigned to any event
Sets default dragging action of selected image in edited EHtml/Auto type cell to "Shift" and floating image in Img attribute to "MoveXY".
If image is dragged without any control button, it is moved in one direction.
new 15.0 <Actions>

DragImageCopy

Not assigned to any event
Sets default dragging action of selected image in edited EHtml/Auto type cell and floating image in Img attribute to "Copy".
If image is dragged without any control button, it is copied and moved.
new 15.0 <Actions>

DragImageCopyXY

Not assigned to any event
Sets default dragging action of selected image in edited EHtml/Auto type cell and floating image in Img attribute to "CopyXY".
If image is dragged without any control button, it is copied and moved in one direction.
new 15.0 <Actions>

DragImageNone

Not assigned to any event
Sets default dragging action of selected image in edited EHtml/Auto type cell and floating image in Img attribute to "".
The image cannot be dragged without any control button.
new 15.0 <Actions>

DragImageClear

Not assigned to any event
Clears default dragging action of selected image in edited EHtml / Auto cell and floating image in Img attribute.
If image is dragged without any control button, its action is chosen by DragImg attribute.
new 15.0 <Cfg> string[]

RestoreImg

["Size,Rotation,Position"]
Comma separated list of actions done when double clicked on image edited in EHtml / Auto type cell and by action RestoreImage. Case insensitive.
The available actions:
Size - shows the image in its default width and height.
Rotation - sets the image rotation to 0 degrees.
Position - restores defaut position of text image.
Left - moves floating image to the left edge of the cell.
Top - moves floating image to the top edge of the cell.
There are also attributes with suffix for every combination of control keys and mouse buttons in this order: Shift,Ctrl,Alt,Meta,Left,Middle,Right. For example RestoreImgCtrlRight will be read if double clicked by right mouse button and pressed Ctrl.
new 15.0 <Actions>

RestoreImage

Not assigned to any event
Restores attributes set by RestoreImg of edited image in EHtml / Auto type cell and floating image in Img attribute to default settings.
new 15.0 <Actions>

RestoreImageSize

Not assigned to any event
Restores size of edited image in EHtml/Auto type cell and floating image in Img attribute to default settings. Removes the width and height attributes.
new 15.0 <Actions>

RestoreImagePosition

Not assigned to any event
Restores position of edited image in EHtml/Auto type cell and floating image in Img attribute to default settings. Places the image to the top left corner of the cell.
new 15.0 <Actions>

RestoreImageRotation

Not assigned to any event
Restores rotation of edited image in EHtml/Auto type cell and floating image in Img attribute to default settings. Removes the rotate setting and the image is rotated to 0 degrees.
new 15.0 API event bool

OnAssignImage

(TGrid grid, TRow row, string col, TRow oldrow, string oldcol, type image)
Called before image is moved from cell [oldrow,oldcol] to cell [row,col] due InsertImg["assign"] or action AssignImage.
image is HTMLElement if changing edited text image or string as Img attribute value if changing floating image.
new 15.0 API event string

OnChangeImage

(TGrid grid, TRow row, string col, string val, string old)
Called before Img attribute is changed from old to val in given cell.
Return new value to set to Img attribute or null to use actual val.
new 15.0 <Actions>

AssignImage

Not assigned to any event
Moves actual floating image to another cell after moved or rotated to be the cell always top left corner.
new 15.0 <Actions>

DeleteImage

Not assigned to any event
Deletes actual floating image or edited text image.
new 15.0 <Actions>

DuplicateImage

Not assigned to any event
Creates a copy of actual floating image or edited text image and places it on the same place.
new 15.0 <Actions>

EnterImageOpacity

Not assigned to any event
Shows prompt dialog to enter an opacity of actual floating image or edited text image.
new 15.0 <Actions>

EnterImageName

Not assigned to any event
Shows prompt dialog to enter a name of actual floating image or edited text image.
new 15.0 <Actions>

FloatImage

Not assigned to any event
Creates floating image from edited text image. Removes the image from text, finishes editing and places it to the Img attribute.
new 15.0 <Actions>

TextImage

Not assigned to any event
Creates text image from actual floating image. Removes the image from the Img attribute and places it to the end of the cell value as <img> tag. Only if the cell is type of EHtml or Auto.
new 15.0 API method bool

DeleteImg

(TRow row, string col, int idx, bool refresh, bool undo)
Deletes one image in given cell on position idx in Img attribute.
If set refresh, it shows changes in grid. If set undo, the change is added to undo queue.
Returns true for success, false for failure.
new 15.0 API method bool

CopyImg

(TRow row, string col, int idx, bool refresh, bool undo)
Creates a copy of one image in given cell on position idx in Img attribute. The copied image is put to the idx+1 position.
If set refresh, it shows changes in grid. If set undo, the change is added to undo queue.
Returns true for success, false for failure.
new 15.0 API method type

ChangeImg

(TRow row, string col, int idx, float[] val, bool assign, bool refresh, bool undo)
Changes attributes of one image in given cell on position idx in Img attribute.
The val is an array of Img attributes:[x,y,width,height,rotate,opacity]. If the array value is null, it is not changed. val can be null to only assign the image.
If set assign, the image can be moved to its top left cell. In this case returns the new cell as array as [row,col].
If set refresh, it shows changes in grid. If set undo, the change is added to undo queue.
Returns true for success, false for failure.