Home
About
Testimonials
Demos
Download
Documentation
Blogs
Forum
Support
Forum
Help
Search
Chatroom
Login
Register
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email?
Jul. 05, 2008, 04:49:19 PM
45332
Posts in
9917
Topics by
4987
Members
Latest Member:
peepahk
News
:
PRADO 3.1.1 is released!
The PRADO Community
»
Prado v3.x
»
General Discussion
»
Active Controls (Ajax)
»
my TActiveDataGrid
« previous
next »
Pages:
[
1
]
2
Author
Topic: my TActiveDataGrid (Read 8010 times)
maisam
Senior Member
Karma: 5
Offline
Posts: 108
my TActiveDataGrid
«
on:
Sep. 22, 2006, 06:55:51 AM »
hello to all
I needed a TActiveDataGrid with Active paging, I writed this class, and it is working.
please give me your idea.
thanks.
TActiveDataGrid.php
Code:
<?php
class
TActiveDataGrid
extends
TDataGrid
{
private
$_PagingRecord
;
public function
onPreRender
(
$param
)
{
parent
::
onPreRender
(
$param
);
if(!
$this
->
Page
->
IsCallBack
)
{
$this
->
getPage
()->
getClientScript
()->
registerEndScript
(
"JS"
.
$this
->
getID
(),
'
function Paging'
.
$this
->
getID
().
'(command, param)
{
new Prado.Callback(\'callbackPageItem'
.
$this
->
getID
().
'\',
{CommandName:command, CommandParameter:param}, null,
{\'CausesValidation\':false, \'onSuccess\': LoadNewData});
}
function LoadNewData(request, result){/*Success*/}
'
);
}
}
public function
onLoad
(
$param
)
{
parent
::
onLoad
(
$param
);
$t1
= new
TCallBack
();
$t1
->
setID
(
"callbackPageItem"
.
$this
->
getID
());
$t1
->
attachEventHandler
(
"OnCallBack"
, array(
$this
,
"Paging"
));
$this
->
getParent
()->
getControls
()->
add
(
$t1
);
$t
= new
TActivePanel
();
$t
->
setID
(
"DataGridPanel"
.
$this
->
getID
());
$this
->
getParent
()->
getControls
()->
add
(
$t
);
$t
->
getControls
()->
add
(
$this
->
getParent
()->
FindControl
(
$this
->
getID
()));
}
public function
getPagingRecord
()
{
return
$this
->
_PagingRecord
;
}
public function
setPagingRecord
(
$v
)
{
$this
->
_PagingRecord
=
$v
;
}
public function
Paging
(
$s
,
$p
)
{
if(
$p
->
Parameter
->
CommandParameter
==
'>'
)
$p
->
Parameter
->
CommandParameter
=
$this
->
getCurrentPageIndex
()+
2
;
else if(
$p
->
Parameter
->
CommandParameter
==
'<'
)
$p
->
Parameter
->
CommandParameter
=
$this
->
getCurrentPageIndex
();
$this
->
setCurrentPageIndex
(
$p
->
Parameter
->
CommandParameter
-
1
);
$this
->
DataSource
=
call_user_func
(array(
$this
->
Page
,
$this
->
getPagingRecord
()), (
$p
->
Parameter
->
CommandParameter
-
1
)*
$this
->
getPagesize
(),
$this
->
getPagesize
());
$this
->
DataBind
();
$this
->
renderDataGrid
();
}
public function
renderDataGrid
()
{
$panel
=
$this
->
getParent
()->
FindControl
(
"DataGridPanel"
.
$this
->
getID
());
$panel
->
renderControl
(
$this
->
getPage
()->
getResponse
()->
createHtmlWriter
());
}
protected function
createPagerButton
(
$buttonType
,
$enabled
,
$text
,
$commandName
,
$commandParameter
)
{
if(
$buttonType
===
'LinkButton'
)
{
if(
$enabled
)
$button
=new
THyperLink
();
else
{
$button
=new
TLabel
;
$button
->
setText
(
$text
);
return
$button
;
}
}
else
{
$button
=new
THyperLink
();
if(!
$enabled
)
$button
->
setEnabled
(
false
);
}
$button
->
Attributes
->
OnClick
=
"Paging"
.
$this
->
getID
().
"('page', '$text')"
;
$button
->
setText
(
$text
);
$button
->
setNavigateUrl
(
"javascript:void(0);"
);
return
$button
;
}
}
?>
sample.page
Code:
<com:TActiveDataGrid ID="meisam" PagingRecord="getDataGridRecord" />
sample.php
Code:
........
public function getDataGridRecord($offset, $limit)
{
global $records;
$records = array(
array("name"=>"meisam1"),
array("name"=>"meisam2"),
array("name"=>"meisam3"),
array("name"=>"meisam4"),
array("name"=>"meisam5"),
array("name"=>"meisam6"),
array("name"=>"meisam7"),
array("name"=>"meisam8"),
array("name"=>"meisam9"),
array("name"=>"meisam10"),
array("name"=>"meisam11"),
array("name"=>"meisam12"),
array("name"=>"meisam13"),
array("name"=>"meisam14"),
array("name"=>"meisam15"),
array("name"=>"meisam16"),
array("name"=>"meisam17"),
array("name"=>"meisam18"),
array("name"=>"meisam19"),
array("name"=>"meisam20"),
array("name"=>"meisam21"),
array("name"=>"meisam22"),
array("name"=>"meisam23"),
array("name"=>"meisam24"),
array("name"=>"meisam25"),
array("name"=>"meisam26"),
array("name"=>"meisam27"),
array("name"=>"meisam28"));
return array_slice($records, $offset, $limit);
}.........
«
Last Edit: Sep. 22, 2006, 06:57:38 AM by maisam
»
Logged
vincedev
Senior Member
Karma: 12
Offline
Posts: 349
Weather seems cold today...
Re: my TActiveDataGrid
«
Reply #1 on:
Sep. 28, 2006, 07:37:19 AM »
Hi maisam,
I'm very interested by tour Datagrid, but It doesn't work...
There just the js script of your OnPreRender method wich is parse in the HTML...
rendered HTML code:
Code:
<form id="ctl0" method="post" action="/demos/personal/index.php?page=test"><div>
<input type="hidden" name="PRADO_PAGESTATE" id="PRADO_PAGESTATE" value="eJxVjU0OAiEUg+/CCXgIIz63JsbdXKH8GSK4EHYT7y4zG2JX/Zo2ld5ocsEFHQgGycIYWmAlJTtSk5xT7uwVmHjLLK+HaaxZ+F6kGHyaTDtL3r6NlRoJSnHwrxXP+Oix1pgb6uzQhcUNHfdPDivesczCcbKw+J/s+gH56ji4" />
</div>
<script type="text/javascript" src="/demos/personal/assets/256d30f8/clientscripts.php?js=prado,logger,effects,ajax&mode=debug"></script>
<div>Press ALT-D (Or CTRL-D on OS X) to toggle the javascript log console (<a href="http://gleepglop.com/javascripts/logger/" target="_blank">more info</a>).</div>
<div id="DataGridPanelmeisam"></div><script type="text/javascript">
/*<![CDATA[*/
function Pagingmeisam(command, param)
{
new Prado.Callback('callbackPageItemmeisam',
{CommandName:command, CommandParameter:param}, null,
{'CausesValidation':false, 'onSuccess': LoadNewData});
}
function LoadNewData(request, result){/*Success*/}
/*]]>*/
</script>
</form>
Logged
.......Vince.......
maisam
Senior Member
Karma: 5
Offline
Posts: 108
Re: my TActiveDataGrid
«
Reply #2 on:
Oct. 03, 2006, 04:53:24 AM »
hello
please use from this simple sample project. and tel me your idea.
thank you very mutch.
Logged
gori
Senior Member
Karma: 12
Offline
Posts: 119
Re: my TActiveDataGrid
«
Reply #3 on:
Dec. 14, 2006, 01:33:43 PM »
No effect
No errors, but no effect when clicking pages... Maybe anybody has working result?
Logged
+1 Carma will be great
http://prado-ua.com
maisam
Senior Member
Karma: 5
Offline
Posts: 108
Re: my TActiveDataGrid
«
Reply #4 on:
Dec. 15, 2006, 07:21:07 AM »
hello
in TActiveDataGrid.php file change function paging to below function ,beacuse of in new version framework change parameter to callbackparameter
Code:
public function Paging($s, $p)
{
if($p->CallbackParameter->CommandParameter=='>') $p->CallbackParameter->CommandParameter = $this->getCurrentPageIndex()+2;
else if($p->CallbackParameter->CommandParameter=='<') $p->CallbackParameter->CommandParameter = $this->getCurrentPageIndex();
$this->setCurrentPageIndex($p->CallbackParameter->CommandParameter-1);
$this->DataSource = call_user_func(array($this->getTemplateControl(), $this->getPagingRecord()), ($p->CallbackParameter->CommandParameter-1)*$this->getPagesize(), $this->getPagesize());
$this->DataBind();
$this->renderDataGrid();
}
Logged
tanhs
Senior Member
Karma: 2
Offline
Posts: 169
Re: my TActiveDataGrid
«
Reply #5 on:
Dec. 15, 2006, 08:05:45 AM »
Thanks. It works.
By the way, I saw you post on
http://www.pradosoft.com/forum/index.php/topic,5721.0.html
did you managed to resolve the issue? I was falling into that trap too.
Tq.
Logged
gori
Senior Member
Karma: 12
Offline
Posts: 119
Re: my TActiveDataGrid
«
Reply #6 on:
Dec. 15, 2006, 11:38:56 AM »
Yes! It's works.
Your
$Carma ++;
And now i can add active button to operate with data in grid?
Thanks a lot for fix.
Logged
+1 Carma will be great
http://prado-ua.com
Knut
PRADO v3.x Developer
Senior Member
Karma: 9
Offline
Posts: 270
Re: my TActiveDataGrid
«
Reply #7 on:
Dec. 15, 2006, 01:34:25 PM »
Wow maisam
This one was really nice.
Logged
urdalen.com
|
Suddenly Oslo
|
wsdl2php
eirikhm
Platinum Member
Karma: 26
Offline
Posts: 752
Re: my TActiveDataGrid
«
Reply #8 on:
Dec. 16, 2006, 10:39:27 AM »
Good work. I'd like to see it added to Prado if Wei / Qiang likes it:)
Logged
Telio Telecom
|
eirikhoem.net
|
My blog
maisam
Senior Member
Karma: 5
Offline
Posts: 108
Re: my TActiveDataGrid
«
Reply #9 on:
Dec. 16, 2006, 12:56:45 PM »
Quote
Thanks. It works.
By the way, I saw you post on
http://www.pradosoft.com/forum/index.php/topic,5721.0.html
did you managed to resolve the issue? I was falling into that trap too.
Tq.
yes, resolved.
use from this method (for example):
Code:
$button->attachEventHandler("onCallback", array($this, "Paging"));
Logged
maisam
Senior Member
Karma: 5
Offline
Posts: 108
Re: my TActiveDataGrid
«
Reply #10 on:
Dec. 16, 2006, 01:04:37 PM »
Quote
And now i can add active button to operate with data in grid?
YES, this class work as same as datagrid.
Logged
tanhs
Senior Member
Karma: 2
Offline
Posts: 169
Re: my TActiveDataGrid
«
Reply #11 on:
Dec. 18, 2006, 08:54:49 AM »
Hi,
Following maisam foot print, I have made myself a new TPager. I hope it will be helpful to someone.
Thanks maisam.
Logged
gori
Senior Member
Karma: 12
Offline
Posts: 119
Re: my TActiveDataGrid
«
Reply #12 on:
Dec. 18, 2006, 01:05:12 PM »
Quote from: tanhs on Dec. 18, 2006, 08:54:49 AM
Hi,
Following maisam foot print, I have made myself a new TPager. I hope it will be helpful to someone.
Thanks maisam.
Great! Now avaible for TRepeater
maisam, is it difficult to add dynamic sorting to your component? and how to add Ajax buttons exit/delete/custom ? Can you make small example for me?
Thanks in advance!
Logged
+1 Carma will be great
http://prado-ua.com
maisam
Senior Member
Karma: 5
Offline
Posts: 108
Re: my TActiveDataGrid
«
Reply #13 on:
Dec. 20, 2006, 03:13:22 PM »
hello to all
for insert paging a datagrid,.. into special cell or layer you can not use from activedatagrid
you can user from activepager.
Logged
gori
Senior Member
Karma: 12
Offline
Posts: 119
Re: my TActiveDataGrid
«
Reply #14 on:
Dec. 20, 2006, 03:27:12 PM »
So, ActiveGrid is out of date? Ok. Let's use Active pages untill offcial ActiveGrid realise, or i think
maisam
's become official
I add small function to Active grid for own use, but maybe it will be usefull for someone
Code:
public function Refresh()
{
$this->DataSource = call_user_func(array($this->getTemplateControl(), $this->getPagingRecord()), ($p->CallbackParameter->CommandParameter-1)*$this->getPagesize(), $this->getPagesize());
$this->DataBind();
$this->renderDataGrid();
}
Code:
$this->DataGrid->Refresh();
Logged
+1 Carma will be great
http://prado-ua.com
Pages:
[
1
]
2
« previous
next »
Jump to:
Please select a destination:
-----------------------------
General
-----------------------------
=> Announcements
=> Prado-powered Applications
=> Prado International
===> Chinese
===> Dutch
===> French
===> German
===> Indonesian
===> Italian
===> Japanese
===> Polish
===> Portuguese
===> Russian
===> Spanish
=> Job Opportunities
-----------------------------
Prado v3.x
-----------------------------
=> General Discussion
===> Active Controls (Ajax)
===> Database
===> JavaScript
===> General PHP Topics
===> PRADO Extension
=> Installation and Setup
=> Feature Requests
=> Bug Reports
=> Tips, Snippets and Tutorials
===> Screencasts
=> Component Repository
-----------------------------
Prado-related Projects
-----------------------------
=> PRADO Community Project
=> PetShop Project
=> Entity framework
=> IDE/Editor for Prado
-----------------------------
Prado v2.x
-----------------------------
=> General Discussion
===> Installation and Setup
===> Active Controls (Ajax)
===> Feature Requests
=> Bug Reports
=> Tips, Snippets and Tutorials
=> Component Repository
-----------------------------
Beyond Prado
-----------------------------
=> Miscellaneous
Terms of Service
|
Contact Us
Copyright © 2006-2007 by the PRADO Group.
Powered by SMF 1.1.5
|
SMF © 2006, Simple Machines LLC
Loan
|
Mortgages
|
Life Insurance
|
MPAA
|
Magazine Subscriptions