Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
f95be734
Commit
f95be734
authored
Sep 20, 2014
by
Kartik Visweswaran
Committed by
Qiang Xue
Sep 22, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Created beforeFilter and afterFilter grid events
Events `beforeFilter.yiiGridView` and `afterFilter.yiiGridView` javascript events created for advanced use cases.
parent
48d22042
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
4 deletions
+37
-4
yii.gridView.js
framework/assets/yii.gridView.js
+37
-4
No files found.
framework/assets/yii.gridView.js
View file @
f95be734
...
...
@@ -28,6 +28,31 @@
var
gridData
=
{};
var
gridEvents
=
{
/**
* beforeFilter event is triggered before filtering the grid.
* The signature of the event handler should be:
* function (event, form)
* where
* - event: an Event object.
* - form: is the grid filter form that will be submitted
*
* If the handler returns a boolean false, it will stop further form validation after this event. And as
* a result, beforeFilter event will not be triggered.
*/
beforeFilter
:
'beforeFilter.yiiGridView'
,
/**
* afterFilter event is triggered after filtering the grid and filtered results are fetched.
* The signature of the event handler should be:
* function (event, form)
* where
* - event: an Event object.
* - form: is the grid filter form that will be submitted
*/
afterFilter
:
'afterFilter.yiiGridView'
};
var
methods
=
{
init
:
function
(
options
)
{
return
this
.
each
(
function
()
{
...
...
@@ -60,7 +85,7 @@
},
applyFilter
:
function
()
{
var
$grid
=
$
(
this
);
var
$grid
=
$
(
this
)
,
event
;
var
settings
=
gridData
[
$grid
.
prop
(
'id'
)].
settings
;
var
data
=
{};
$
.
each
(
$
(
settings
.
filterSelector
).
serializeArray
(),
function
()
{
...
...
@@ -81,10 +106,19 @@
$
.
each
(
data
,
function
(
name
,
value
)
{
$form
.
append
(
$
(
'<input type="hidden" name="t" value="" />'
).
attr
(
'name'
,
name
).
val
(
value
));
});
// triggers a beforeFilter grid event with the filter form as a parameter
event
=
$
.
Event
(
gridEvents
.
beforeFilter
);
$form
.
trigger
(
event
,
[
$form
]);
if
(
event
.
result
===
false
)
{
return
;
}
$form
.
submit
();
// triggers a filter grid event with the filter form as a parameter
$grid
.
trigger
(
'filter.yiiGridView'
,
[
$form
]);
// triggers a afterFilter grid event with the filter form as a parameter
event
=
$
.
Event
(
gridEvents
.
afterFilter
);
$grid
.
trigger
(
event
,
[
$form
]);
},
setSelectionColumn
:
function
(
options
)
{
...
...
@@ -129,4 +163,3 @@
}
};
})(
window
.
jQuery
);
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment