Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Previous revision
wiki:events [2014/05/04 07:43]
wiki:events [2018/02/02 20:54] (current)
admin
Line 1: Line 1:
-~~ODT~~ 
 ====== Events ====== ====== Events ======
  
Line 5: Line 4:
 The action to take on an event is set as a property of the grid, e.g. The action to take on an event is set as a property of the grid, e.g.
  
-See also [[wiki:​methods|jqGrid Methods]].+See also [[wiki:​methods|jqGrid Methods]]
  
 <code javascript>​ <code javascript>​
Line 68: Line 67:
  
 ===== List of triggered events (new in v4.3.2) ===== ===== List of triggered events (new in v4.3.2) =====
-^Event^Parameters^Description^ +^Event^Parameters^Return value^Description^ 
-|jqGridResizeStart|...|...| +|jqGridResizeStart|...|none|...| 
-|jqGridResizeStop|...|...| +|jqGridResizeStop|...|none|...| 
-|jqGridAfterInsertRow|...|...| +|jqGridRowAttr|...|...|...| 
-|jqGridGridComplete|none|...| +|jqGridAfterInsertRow|...|none|...| 
-|jqGridAfterGridComplete|none|...| +|jqGridGridComplete|none|none|...| 
-|jqGridBeforeRequest|none|...| +|jqGridAfterGridComplete|none|none|...| 
-|jqGridLoadComplete|...|...| +|jqGridBeforeRequest|none|...|...| 
-|jqGridAfterLoadComplete|...|...| +|jqGridLoadComplete|...|none|...| 
-|jqGridSortCol|...|...| +|jqGridAfterLoadComplete|...|none|...| 
-|jqGridSelectAll|...|...| +|jqGridSortCol|...|...|...| 
-|jqGridBeforeSelectRow|...|...| +|jqGridSelectAll|...|none|...| 
-|jqGridCellSelect|...|...| +|jqGridBeforeSelectRow|...|...|...| 
-|jqGridDblClickRow|...|...| +|jqGridCellSelect|...|none|...| 
-|jqGridRightClickRow|...|...| +|jqGridDblClickRow|...|...|...| 
-|jqGridHeaderClick|...|...| +|jqGridRightClickRow|...|...|...| 
-|jqGridSelectRow|...|...| +|jqGridHeaderClick|...|none|...| 
-|jqGridShowHideCol|...|...| +|jqGridSelectRow|...|none|...| 
-|jqGridRemapColumns|...|...| +|jqGridShowHideCol|...|none|...| 
-|jqGridKeyLeft|...|...| +|jqGridRemapColumns|...|none|...| 
-|jqGridKeyRight|...|...| +|jqGridKeyLeft|...|none|...| 
-|jqGridKeyEnter|...|...| +|jqGridKeyRight|...|none|...| 
-|jqGridKeySpace|...|...| +|jqGridKeyEnter|...|none|...| 
-|jqGridToolbarBeforeSearch|none|...| +|jqGridKeySpace|...|none|...| 
-|reloadGrid|...|...| +|jqGridToolbarBeforeSearch|none|...|...| 
-|jqGridToolbarAfterSearch|none|...| +|reloadGrid|...|none|...| 
-|jqGridToolbarBeforeClear|none|...| +|jqGridToolbarAfterSearch|none|none|...| 
-|jqGridToolbarAfterClear|none|...| +|jqGridToolbarBeforeClear|none|...|...| 
-|jqGridFilterBeforeShow|...|...| +|jqGridToolbarAfterClear|none|none|...| 
-|jqGridFilterAfterShow|...|...| +|jqGridFilterBeforeShow|...|...|...| 
-|jqGridFilterInitialize|...|...| +|jqGridFilterAfterShow|...|none|...| 
-|jqGridFilterSearch|none|...| +|jqGridFilterInitialize|...|none|...| 
-|jqGridFilterReset|none|...| +|jqGridFilterSearch|none|...|...| 
-|jqGridAddEditBeforeCheckValues|...|...| +|jqGridFilterReset|none|...|...| 
-|jqGridAddEditClickSubmit|...|...| +|jqGridAddEditBeforeCheckValues|...|...|...| 
-|jqGridAddEditBeforeSubmit|...|...| +|jqGridAddEditClickSubmit|...|...|...| 
-|jqGridAddEditErrorTextFormat|...|...| +|jqGridAddEditBeforeSubmit|...|...|...| 
-|jqGridAddEditAfterSubmit|...|...| +|jqGridAddEditErrorTextFormat|...|...|...| 
-|jqGridAddEditAfterComplete|...|...| +|jqGridAddEditAfterSubmit|...|...|...| 
-|jqGridAddEditBeforeInitData|form,​ \\ oper|This event is fired before the dataInit function. \\ //form// is the form as a jQuery object \\ //oper// is the operation type, either "​add"​ or "​edit"​| +|jqGridAddEditAfterComplete|...|none|...| 
-|jqGridAddEditBeforeShowForm|...|...| +|jqGridAddEditBeforeInitData|form,​ \\ oper|...|This event is fired before the dataInit function. \\ //form// is the form as a jQuery object \\ //oper// is the operation type, either "​add"​ or "​edit"​| 
-|jqGridAddEditAfterShowForm|...|...| +|jqGridAddEditBeforeShowForm|...|none|...| 
-|jqGridAddEditInitializeForm|...|...| +|jqGridAddEditAfterShowForm|...|none|...| 
-|jqGridAddEditClickPgButtons|...|...| +|jqGridAddEditInitializeForm|...|none|...| 
-|jqGridAddEditAfterClickPgButtons|...|...| +|jqGridAddEditClickPgButtons|...|none|...| 
-|jqGridInlineEditRow|...|...| +|jqGridAddEditAfterClickPgButtons|...|none|...| 
-|jqGridInlineAfterSaveRow|...|...| +|jqGridInlineEditRow|...|none|...| 
-|jqGridInlineSuccessSaveRow|...|...| +|jqGridInlineAfterSaveRow|...|none|...| 
-|jqGridInlineErrorSaveRow|...|...| +|jqGridInlineSuccessSaveRow|...|...|...| 
-|jqGridInlineAfterRestoreRow|...|...| +|jqGridInlineErrorSaveRow|...|none|...| 
-|jqGridBeforeEditCell|...|...| +|jqGridInlineAfterRestoreRow|...|none|...| 
-|jqGridAfterEditCell|...|...| +|jqGridBeforeEditCell|...|none|...| 
-|jqGridSelectCell|...|...| +|jqGridAfterEditCell|...|none|...| 
-|jqGridBeforeSaveCell|...|...| +|jqGridSelectCell|...|none|...| 
-|jqGridBeforeSubmitCell|...|...| +|jqGridBeforeSaveCell|...|...|...| 
-|jqGridAfterSubmitCell|...|...| +|jqGridBeforeSubmitCell|...|...|...| 
-|jqGridAfterSaveCell|...|...| +|jqGridAfterSubmitCell|...|...|...| 
-|jqGridErrorCell|...|...| +|jqGridAfterSaveCell|...|none|...| 
-|jqGridAfterRestoreCell|...|...| +|jqGridErrorCell|...|none|...| 
-|jqGridSubGridBeforeExpand|...|...| +|jqGridAfterRestoreCell|...|none|...| 
-|jqGridSubGridRowExpanded|...|...| +|jqGridSubGridBeforeExpand|...|...|...| 
-|jqGridSubGridRowColapsed|...|...| +|jqGridSubGridRowExpanded|...|none|...| 
-|jqGridGroupingClickGroup|...|...| +|jqGridSubGridRowColapsed|...|...|...| 
-|jqGridImportComplete|...|...|+|jqGridGroupingClickGroup|...|none|...| 
 +|jqGridImportComplete|...|none|...| 
 + 
 +===== Return values from triggered events ===== 
 +Some from events in the above list should or have to return events. One should take in the consideration that one can register multiple event handles. The event handle should use **[[http://​api.jquery.com/​event.result/​|result]]** property of the event object to know the value returned from the previously invoked event handler. Depend on the type of returned value one should combine the results which one plan to return with the results returned by previous handler. 
 + 
 +For example one implements **jqGridBeforeSelectRow** event handler which can return boolean **true**/​**false** or **"​stop"​** string. The event will be called on click inside of the grid. jqGrid trigger **jqGridBeforeSelectRow** event before making selection of the clicked row. If the returned value is **false** or **"​stop"​**,​ jqGrid will don't make selection. So it should be clear that **jqGridBeforeSelectRow** event handler can return **false** if one decide to suppress row selection, but one couldn'​t just return **true** if the selection should be permitted. It will force selection even if //​previously//​ invoked event handler returns **false**. So one have to test **[[http://​api.jquery.com/​event.result/​|result]]** property of **e** parameter. If it's **undefined** then there are no other event handler which was invoked previously. On the other side if the value **e.result** is **false** or **"​stop"​** then the //​previously//​ invoked event handler decide to suppress selection. In the case one have to return the value **e.result** (**false**) instead of **true**. It means that we don't want to //force// the selection. We just //​don'​t protest the selection// and we want to follow the decision of //​previously//​ invoked event handler about the selection. The corresponding code could be the following:​ 
 + 
 +<code javascript>​ 
 +$("​gridid"​).bind("​jqGridBeforeSelectRow",​ function (e, rowid, orgClickEvent) { 
 +    ... 
 +    // if we want to return true, we should test e.result additionally 
 +    return e.result === undefined ? true : e.result; 
 +}); 
 +</​code>​ 
 + 
 +Alternatively one can test explicitly for for false or "​stop":​ 
 + 
 +<code javascript>​ 
 +$("​gridid"​).bind("​jqGridBeforeSelectRow",​ function (e, rowid, orgClickEvent) { 
 +    ... 
 +    // if we want to return true, we should test e.result additionally 
 +    return e.result === false || e.result === "​stop"​ ? false : true; 
 +}); 
 +</​code>​
  
 ===== Execution Order ===== ===== Execution Order =====
Line 144: Line 167:
   - loadComplete   - loadComplete
    
- 
  
  

QR Code
QR Code wiki:events (generated for current page)