Welcome, Guest. Please login or register.
Did you miss your activation email?
Feb. 09, 2010, 03:35:27 PM
52593 Posts in 11677 Topics by 7491 Members
Latest Member: peerjee
News: Share your PRADO experience with other PRADOers by commenting on the QuickStart Tutorial.
 
The PRADO Community » Prado v3.x » General Discussion » Active Controls (Ajax) » my TActiveDataGrid « previous next »
Pages: [1] 2 Print
Author Topic: my TActiveDataGrid  (Read 14078 times)
maisam
Senior Member
***

Karma: 5
Offline Offline

Posts: 111


View Profile
« 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 Offline

Posts: 349


Weather seems cold today...


View Profile
« 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&amp;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 Offline

Posts: 111


View Profile
« 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: 13
Offline Offline

Posts: 119



View Profile WWW
« Reply #3 on: Dec. 14, 2006, 01:33:43 PM »

No effect Sad No errors, but no effect when clicking pages... Maybe anybody has working result?
Logged

+1 Carma will be great Smiley http://prado-ua.com
maisam
Senior Member
***

Karma: 5
Offline Offline

Posts: 111


View Profile
« 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 Offline

Posts: 169


View Profile
« 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: 13
Offline Offline

Posts: 119



View Profile WWW
« Reply #6 on: Dec. 15, 2006, 11:38:56 AM »

Yes! It's works.

Your $Carma ++; Smiley

And now i can add active button to operate with data in grid?

Thanks a lot for fix.
Logged

+1 Carma will be great Smiley http://prado-ua.com
Knut
PRADO v3.x Developer
Senior Member
*****

Karma: 11
Offline Offline

Posts: 315



View Profile WWW
« Reply #7 on: Dec. 15, 2006, 01:34:25 PM »

Wow maisam Smiley This one was really nice.
Logged

eirikhm
PRADO v3.x Developer
Platinum Member
*****

Karma: 30
Offline Offline

Posts: 845



View Profile WWW
« 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

maisam
Senior Member
***

Karma: 5
Offline Offline

Posts: 111


View Profile
« 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 Offline

Posts: 111


View Profile
« 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 Offline

Posts: 169


View Profile
« 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: 13
Offline Offline

Posts: 119



View Profile WWW
« Reply #12 on: Dec. 18, 2006, 01:05:12 PM »

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 Smiley
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 Smiley http://prado-ua.com
maisam
Senior Member
***

Karma: 5
Offline Offline

Posts: 111


View Profile
« 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: 13
Offline Offline

Posts: 119



View Profile WWW
« 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 Smiley

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 Smiley http://prado-ua.com
Pages: [1] 2 Print 
« previous next »
Jump to: