Get KoolPHP UI with 30% OFF!

Integrate KoolControls in CodeIgniter PHP Framework

Michael
Hello,
I can use KoolControls in a standalone project without any problems, see code below:
<?php 
    /*
     * Please put this file in the same folder with KoolControls folder
     * or you may modify path of require and scriptFolder to refer correctly
     * to koolgrid.php and its folder.
     */
    include "KoolControls/KoolGrid/koolgrid.php";
    include "KoolControls/KoolAjax/koolajax.php";
    include "KoolControls/KoolGrid/ext/datasources/PDODataSource.php";
    $koolajax->scriptFolder = "KoolControls/KoolAjax";
 
    
    $DB_HOST = 'localhost'; //Host name<br>
    $DB_USER = 'sakila'; //Host Username<br>
    $DB_PASS = 'caroline'; //Host Password<br>
    $DB_NAME = 'sakila'; //Database name<br><br>
    $ds = new PDODataSource(new PDO ("mysql:host=$DB_HOST; dbname=$DB_NAME;", $DB_USER, $DB_PASS, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"))); // PDO Connection
 
    $ds->SelectCommand = "select actor_id, first_name, last_name from actor";
 
    $grid = new KoolGrid("grid");
    $grid->scriptFolder = "KoolControls/KoolGrid";
    $grid->DataSource = $ds;
    
    
 
    $grid->styleFolder = "default";
    $grid->Width = "655px";
    $grid->Height = "300px";
    $grid->PageSize = 25;
    $grid->AjaxEnabled = true;
    $grid->KeepRowStateOnRefresh = true;
    $grid->AllowScrolling = true;
    
    $column = new GridBoundColumn();
    $column->DataField = "first_name";
    $column->HeaderText = "Vorname";
    $column->Width = "45%";
    $grid->MasterTable->AddColumn($column);
    
    $column = new GridBoundColumn();
    $column->DataField = "last_name";
    $column->HeaderText = "Nachname";
    $column->Width = "45%";
    $grid->MasterTable->AddColumn($column);
    
    $column = new GridBoundColumn();
    $column->DataField = "actor_id";
    $column->HeaderText = "ID";
    $column->Width = "10%";
    $grid->MasterTable->AddColumn($column);
    
    $grid->MasterTable->AllowHovering = true;
    $grid->MasterTable->VirtualScrolling = true;
    $grid->MasterTable->AllowSelecting = true;
    $grid->MasterTable->AutoGenerateColumns = false;
    $grid->MasterTable->AutoGenerateDeleteColumn = false;
    $grid->MasterTable->AutoGenerateExpandColumn = false;
    $grid->MasterTable->Width = "655px";
    $grid->MasterTable->RowAlternative = true;
    $grid->MasterTable->Pager = new GridPrevNextAndNumericPager();
 
 
    $grid->Process();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>KoolGrid</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    </head>
    <body>
        <form id="form1" method="post"> <!-- You should render the grid inside a form tag, in case $grid->AjaxEnabled = false the grid needs a form to operate. -->
		<?php echo $koolajax->Render();?>
		<?php echo $grid->Render();?>
	</form>
    </body>
</html>

This gives me a nice grid with default style, virtual scrolling, ajax and pager:

However, if I put the very same code in a view file in CodeIgniter and the KoolControls folder in the same folder, I am getting a grid without style, virtualscrolling and pager which does not work:

Here is the directory structure:

I dont know why KoolGrid works nicely as standalone, and not inside CodeIgniter.
Note, ideally, the KoolControls folder should not reside in the a particular view folder of CodeIgniter, but directly in the 'view' folder so it can be used from all views, but i could not make this work either.
KoolControls are real good components, but if they don't play nicely together with PHP Frameworks, they are worthless. No one will build complex PHP applications without a framework.
I hope you guys at KoolPHP will fix this soon.
Posted Jul 5, 2016 , edited Jul 5, 2016 Kool
Peter
Hi Michael,
Please do this:
1. Put the KoolControls folder in the "assets" folder of CodeIgniter.
2. In the Controller action, please make "require" to KoolGrid as you normally do.
3. Important:
$grid->styleFolder="default";
$grid->scriptFolder= URL_TO_ASSETS."/KoolControls/KoolGrid";

Where URL_TO_ASSETS = base_url."/assets"
Posted Jul 6, 2016 , edited Jul 6, 2016 Kool
Michael
Hi Peter,
base_url() . "/assets" is not working and I am getting this message:
Severity: Warning
Message: require(): http:// wrapper is disabled in the server configuration by allow_url_include=0
I tried FCPATH instead:
$this->load->helper('url');
    
    $URL_TO_ASSETS = FCPATH . "assets/";
    require $URL_TO_ASSETS."KoolControls/KoolGrid/koolgrid.php";
    require $URL_TO_ASSETS."KoolControls/KoolAjax/koolajax.php";
    require $URL_TO_ASSETS."KoolControls/KoolGrid/ext/datasources/PDODataSource.php";
    $koolajax->scriptFolder = $URL_TO_ASSETS."KoolControls/KoolAjax";
   
    $grid = new KoolGrid("grid");
    $grid->scriptFolder = $URL_TO_ASSETS."KoolControls/KoolGrid";

but this does not work either, it gives me same blank table as in picture above.
Any suggestions?
Posted Jul 6, 2016 , edited Jul 6, 2016 Kool
Peter
KoolControls folder needed to put somewhere public which browser can access directly (like css or js).
How do you normally includes a JS file or a CSS file in your project? Please try to do the same to set the scriptFolder properties.
Please consider the KoolControls as a folder containing JS file. Basically, client-side need to load javascript code generated from php file of each controls, for example koolgrid.php
Posted Jul 6, 2016 Kool
Peter
If you are able to send me the link to a sample of CodeIngter page with KoolGrid included, I will tell you correct scriptFolder settings right away.
Posted Jul 6, 2016 Kool
Michael
Hi Peter,
Thanks for your explanations. Now I understand. I am running on 127.0.0.1 and I hardcoded this for testing. And now it works ;) Only need to figure out how to dynamically get the correct url at runtime.
Michael
Posted Jul 6, 2016 Kool -
Peter
Awesome! Any difficulty, please let us know.
Posted Jul 6, 2016 Kool -
Garison
The Ionic improvement process is quite simple. Stage one is to foster the application UX and pages structure with UI/UX planner. The following stage where Ionic engineers are required, to foster a rakish based application, the code can be abused by other web designers for Progressive Web Application for instance. The code reuse, for this situation, can be broad. The third stage is to wrap the Angular code into Ionic and markup the perspectives into Ionic UI lattice which is extraordinarily created for portable based gadgets like telephones and tablets. The following stage will be construct and arrangement which incorporate the cloud-based Ionic stage. These are run of the mill phases of the Ionic programming life cycle click site
Posted Aug 30 , edited Sep 1 Kool
Karen
Thanks for this post. part of speech refers to the grammatical category. Which is used to describe words with similar properties. For example, both nouns and verbs are under a category pop over here it is one of the basic knowledge about language. In other words, it is important to understand the hidden meanings in words on the basis of their inherent characteristics.
Posted Oct 21 , edited Oct 21 Kool
brian
Hello, buddies! Catch read review will help you detect mistakes in the text that you would have missed otherwise. This instrument is easy to use, handy, and cost nothing. Anyone may use it, and you'll be pleased with the outcomes, I'm sure. You just need to put your text to it and wait for the verification to be finished. Good luck, pals!
Posted 6 days ago Kool