Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mahara
mahara
Commits
9ed45f15
Commit
9ed45f15
authored
Jun 03, 2009
by
Elliot Pahl
Committed by
Nigel McNie
Jun 04, 2009
Browse files
Make tablerenderer remember the last arguments when using the pager.
parent
0e54b5b9
Changes
1
Hide whitespace changes
Inline
Side-by-side
htdocs/js/tablerenderer.js
View file @
9ed45f15
...
...
@@ -26,6 +26,7 @@ function TableRenderer(target, source, columns, options) {
this
.
rowfunction
=
function
(
rowdata
,
rownumber
,
data
)
{
return
TR
({
'
class
'
:
'
r
'
+
(
rownumber
%
2
)});
}
this
.
updatecallback
=
function
()
{};
this
.
updateOnLoadFlag
=
false
;
this
.
lastArgs
=
{};
this
.
init
=
function
()
{
self
.
table
=
getElement
(
target
);
...
...
@@ -116,9 +117,8 @@ function TableRenderer(target, source, columns, options) {
}
this
.
pageChange
=
function
(
n
)
{
self
.
doupdate
({
'
offset
'
:
(
n
-
1
)
*
self
.
limit
});
self
.
lastArgs
.
offset
=
(
n
-
1
)
*
self
.
limit
;
self
.
doupdate
(
self
.
lastArgs
);
}
this
.
onFirstPage
=
function
()
{
...
...
@@ -175,6 +175,7 @@ function TableRenderer(target, source, columns, options) {
if
(
!
request_args
)
{
request_args
=
{};
}
self
.
lastArgs
=
request_args
;
forEach
(
self
.
statevars
,
function
(
key
)
{
if
(
typeof
(
request_args
[
key
])
==
'
undefined
'
&&
typeof
(
self
[
key
])
!=
'
undefined
'
)
{
...
...
@@ -230,16 +231,19 @@ function TableRenderer(target, source, columns, options) {
};
this
.
goFirstPage
=
function
()
{
self
.
doupdate
({
'
offset
'
:
0
});
self
.
lastArgs
.
offset
=
0
;
self
.
doupdate
(
self
.
lastArgs
);
};
this
.
goPrevPage
=
function
()
{
if
(
self
.
offset
>
0
)
{
if
(
self
.
offset
-
self
.
limit
<
0
)
{
self
.
doupdate
({
'
offset
'
:
0
});
self
.
lastArgs
.
offset
=
0
;
self
.
doupdate
(
self
.
lastArgs
);
}
else
{
self
.
doupdate
({
'
offset
'
:
self
.
offset
-
self
.
limit
});
self
.
lastArgs
.
offset
=
self
.
offset
-
self
.
limit
;
self
.
doupdate
(
self
.
lastArgs
);
}
}
else
{
...
...
@@ -249,7 +253,8 @@ function TableRenderer(target, source, columns, options) {
this
.
goNextPage
=
function
()
{
if
(
self
.
offset
+
self
.
limit
<
self
.
count
)
{
self
.
doupdate
({
'
offset
'
:
self
.
offset
+
self
.
limit
});
self
.
lastArgs
.
offset
=
self
.
offset
+
self
.
limit
;
self
.
doupdate
(
self
.
lastArgs
);
}
else
{
logWarning
(
'
Already on the last page (
'
+
self
.
offset
+
'
,
'
+
self
.
limit
+
'
,
'
+
self
.
count
+
'
)
'
);
...
...
@@ -257,7 +262,8 @@ function TableRenderer(target, source, columns, options) {
};
this
.
goLastPage
=
function
()
{
self
.
doupdate
({
'
offset
'
:
Math
.
floor
(
(
self
.
count
-
1
)
/
self
.
limit
)
*
self
.
limit
});
self
.
lastArgs
.
offset
=
Math
.
floor
(
(
self
.
count
-
1
)
/
self
.
limit
)
*
self
.
limit
;
self
.
doupdate
(
self
.
lastArgs
);
};
this
.
updateOnLoad
=
function
()
{
...
...
Write
Preview
Supports
Markdown
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