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
07c7236b
Commit
07c7236b
authored
Jan 30, 2014
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GridView filter now works with Pjax.
parent
e63a8247
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
4 deletions
+31
-4
yii.gridView.js
framework/assets/yii.gridView.js
+17
-3
yii.js
framework/assets/yii.js
+13
-0
Pjax.php
framework/widgets/Pjax.php
+1
-1
No files found.
framework/assets/yii.gridView.js
View file @
07c7236b
...
@@ -50,6 +50,17 @@
...
@@ -50,6 +50,17 @@
return
;
return
;
}
}
}
}
methods
.
applyFilter
.
apply
(
$e
);
return
false
;
});
});
},
applyFilter
:
function
()
{
var
$grid
=
$
(
this
);
var
settings
=
$grid
.
data
(
'yiiGridView'
).
settings
;
var
data
=
$
(
settings
.
filterSelector
).
serialize
();
var
data
=
$
(
settings
.
filterSelector
).
serialize
();
var
url
=
settings
.
filterUrl
;
var
url
=
settings
.
filterUrl
;
if
(
url
.
indexOf
(
'?'
)
>=
0
)
{
if
(
url
.
indexOf
(
'?'
)
>=
0
)
{
...
@@ -57,10 +68,13 @@
...
@@ -57,10 +68,13 @@
}
else
{
}
else
{
url
+=
'?'
+
data
;
url
+=
'?'
+
data
;
}
}
window
.
location
.
href
=
url
;
return
false
;
$grid
.
find
(
'form.gridview-filter-form'
).
remove
();
});
var
$form
=
$
(
'<form action="'
+
url
+
'" method="get" class="gridview-filter-form" style="display:none" data-pjax></form>'
).
appendTo
(
$grid
);
$
.
each
(
yii
.
getQueryParams
(
url
),
function
(
name
,
value
)
{
$form
.
append
(
$
(
'<input type="hidden" name="t" value="" />'
).
attr
(
'name'
,
name
).
val
(
value
));
});
});
$form
.
submit
();
},
},
setSelectionColumn
:
function
(
options
)
{
setSelectionColumn
:
function
(
options
)
{
...
...
framework/assets/yii.js
View file @
07c7236b
...
@@ -152,6 +152,19 @@ yii = (function ($) {
...
@@ -152,6 +152,19 @@ yii = (function ($) {
return
false
;
return
false
;
},
},
getQueryParams
:
function
(
url
)
{
var
pos
=
url
.
indexOf
(
'?'
);
if
(
pos
<
0
)
{
return
{};
}
var
qs
=
url
.
substring
(
pos
+
1
).
split
(
'&'
);
for
(
var
i
=
0
,
result
=
{};
i
<
qs
.
length
;
i
++
){
qs
[
i
]
=
qs
[
i
].
split
(
'='
);
result
[
decodeURIComponent
(
qs
[
i
][
0
])]
=
decodeURIComponent
(
qs
[
i
][
1
]);
}
return
result
;
},
initModule
:
function
(
module
)
{
initModule
:
function
(
module
)
{
if
(
module
.
isActive
===
undefined
||
module
.
isActive
)
{
if
(
module
.
isActive
===
undefined
||
module
.
isActive
)
{
if
(
$
.
isFunction
(
module
.
init
))
{
if
(
$
.
isFunction
(
module
.
init
))
{
...
...
framework/widgets/Pjax.php
View file @
07c7236b
...
@@ -164,7 +164,7 @@ class Pjax extends Widget
...
@@ -164,7 +164,7 @@ class Pjax extends Widget
$view
=
$this
->
getView
();
$view
=
$this
->
getView
();
PjaxAsset
::
register
(
$view
);
PjaxAsset
::
register
(
$view
);
$js
=
"jQuery(document).pjax(
$linkSelector
,
\"
#
$id
\"
,
$options
);"
;
$js
=
"jQuery(document).pjax(
$linkSelector
,
\"
#
$id
\"
,
$options
);"
;
$js
.=
"jQuery(document).on('submit',
$formSelector
, function (event) {jQuery.pjax.submit(event, '#
$id
');});"
;
$js
.=
"
\n
jQuery(document).on('submit',
$formSelector
, function (event) {jQuery.pjax.submit(event, '#
$id
');});"
;
$view
->
registerJs
(
$js
);
$view
->
registerJs
(
$js
);
}
}
}
}
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