KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Table label=>function() #3399

Open Amr opened this topic on on Nov 29 - 3 comments

Amr commented on Nov 29

Dear Sir I'm trying to make a table with dynamic field label but i always give me error here is the code example $repoact=>array(

			"cssStyle"=>"text-align:right",
			//"label"=>$repoact,
              "label"=> function($repoact)
              {
                  if($repoact==='activity'){return 'OK1';}
                  if($repoact==='service'){return 'OK2';}
                  if($repoact==='sub_service'){return 'OK3';}
                  if($repoact==='user'){return 'OK4';}
                  if($repoact==='branch'){return 'OK5';}

           },
),
Hasan Hashemi commented on Nov 29

Gentleman, maybe you can get what you want with... https://www.koolreport.com/docs/processes/columnrename/

Hasan Hashemi commented on Nov 29

....or you have to extend the table widget

Eugene commented on Nov 30

hi, It looks like your logic depends on $repoact variable only so I suggest to move the logic before your create your Table or even better in your report.php and send the result to the view as a parameter. Anyway if somewhere before Table :: create you have set $repoact this "label"=>$repoact should work.

Or you can try something like this

"label"=> (function($val)
              {
                  if($val==='activity'){return 'OK1';}
                  if(($val==='service'){return 'OK2';}
                  if(($val==='sub_service'){return 'OK3';}
                  if(($val==='user'){return 'OK4';}
                  if($val==='branch'){return 'OK5';}

           })($repoact),

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
None yet

None