[eluser]gyo[/eluser]
PedroGrilo I'm glad you say it so! It is my first target to keep everything SIMPLE!
And btw any suggestion is always welcome
I'd like to give info about my TODO list... so I'm working on:
- fields validation so you can add your own rules
- implementing a way to call a function before and/or after the database query
- implement relational functions to allow more advanced structure of data
cheers!
gyo
[eluser]Atasa[/eluser]
Chao gyo,
by tomorrow the leatest i will post the datagrid component.
But I have to say one thing more.
I don't agree about creating the information for the forms in the php files.
You can create another table in the database with this information like (Data mapping schema information).
In this way it is easier to change setting for your project.
Cheers
[eluser]kucerar[/eluser]
[quote author="suashi" date="1203741930"]Hi kucerar!
ATK is quite advanced and has a very complex structure, and I already found some inspiration... thanks!
[/quote]
Good for you...
Take a look at some of the other Ignited Code threads, a lot of people are finding the same damn problem and reaching for the same damn solution ;-) that ATK has already done. It's been there it's done that, and it's got the t-shirt... There's an offshoot Rails project called Streamlined that has realized the same CRUD thing, Rails is template-driven and we're all tired of that. This is the same problem I faced 8 years ago with plain old JSPs trying to tie 70 odd questionnaire fields to a table without doing too much work.
ATK URLs look nasty however...it was programmed before the trend to friendly URLs. Have to fix that. It's also slow. You'll need eaccelerator to run it due to all the classloading. There's a lot of stuff going on in there, makes me nervous sometimes, but not as nervous as zend framework for some reason.
-R
UPDATE:
Good grief... they have quite a dbforge over there. They generate the tables from the node specification.. check out the Achievo package, in directory modules/setup, there's a setup node that shows example of using their DDL class. I had expected to find examples of using DDL class, and generic field types, which I need to dynamically build tables and be cross-db, but had not expected to find that they define the actual tables in the node, and use those for the source definitions.
[eluser]timj[/eluser]
I like what I'm seeing so far, however, I am getting the following error in my view file, once for every record in my table:
Undefined property: Crud::$options
Filename: libraries/Crud.php
Line Number: 115
As far is I can tell, $options is a conditional (custom options) and I don't see this referenced in your User Guide. I've not assigned any custom options, why am I getting this error?
[eluser]gyo[/eluser]
atasa: I agree that the fields should not be declared in the controller, I was thinking about placing the forms definitions in a model file; in the next release I'll provide an example that uses models. Btw I'll wait for your data grid
Edit: I forgot to say that the library will support a pre-defined schema as well; you can customize it to automatically parse the db fields, or grabbing configuration from a table.
kucerar: then I'll give a deeper look!
...gyo
[eluser]Atasa[/eluser]
Chao gyo
You will have to give some time more 'couse i had a back pain attack, while carrying wood for the fire place.
See you again tomorrow.
Cheers
[eluser]Majd Taby[/eluser]
Guys, take a look at CodeExtinguishers' CodexForms library. It's a very flexible and extendible form generator.
[eluser]gyo[/eluser]
Atasa: take care!
jTaby: I was using your powerful library and I fall in love with it for its versatility, if I'm writing CRUD library is to create an automated system that I can fully understand. Big respect for CodeExtinguisher and Rapyd which are great and advanced tools.
byee
[eluser]Atasa[/eluser]
OK gyo,
I just manage to stand up a bit it was a very painful situation...
But I came with the first attempt for the datagrid while in bed.
You can just bind a multidimensional array.
The array includes:
a. info for the table like Caption and for the pagination.
b. info for the table header
c. info for the the tablebody
d. i have included a basic template on the fly.
Returns a well formed html table and pagination links
What i will like to see more now is how to add dynamically edit + delete buttons.
For me the ideal will be to pass a JavaScript callback function to the buttons
for more user interaction.
But thats the next step.
Cheers
Code: <?php
class Datagrid extends Controller {
function Datagrid()
{
parent::Controller();
$this->load->library('table');
$this->load->helper('url');
$this->load->library('pagination');
}
function index()
{
$tableheader = array();
$tablebody = array();
$paging = array();
$tableData = array(
'tblinfo' => array(
'CAPTION' => 'This is My Datagrid',
'ID_NAME' => 'FIELD_ID',
'PER_PAGE' => 20,
'TOTAL_ROWS' => 200,
'BASE_URL' => 'http://www.example.com/index.php/datagrid/',
) ,
'header' => array(
'FIELD_NAME_1' => 'FIELD 1',
'FIELD_NAME_2' => 'FIELD 2',
'FIELD_NAME_3' => 'FIELD 3',
'FIELD_NAME_4' => 'FIELD 4',
'FIELD_NAME_5' => 'ACTION',
) ,
'grid' => array(
'Row1' => array(
'FIELD_NAME1' => 'RowField 1', 'FIELD_NAME2' => 'RowField 2', 'FIELD_NAME3' => 'RowField 3','FIELD_NAME4' => 'RowField 4',
'FIELD_ID' => 'Row_Id'),
'Row2' => array(
'FIELD_NAME1' => 'RowField 1', 'FIELD_NAME2' => 'RowField 2', 'FIELD_NAME3' => 'RowField 3','FIELD_NAME4' => 'RowField 4',
'FIELD_ID' => 'Row_Id'),
'Row3' => array(
'FIELD_NAME1' => 'RowField 1', 'FIELD_NAME2' => 'RowField 2', 'FIELD_NAME3' => 'RowField 3','FIELD_NAME4' => 'RowField 4',
'FIELD_ID' => 'Row_Id'),
'Row4' => array(
'FIELD_NAME1' => 'RowField 1', 'FIELD_NAME2' => 'RowField 2', 'FIELD_NAME3' => 'RowField 3','FIELD_NAME4' => 'RowField 4',
'FIELD_ID' => 'Row_Id'),
'Row5' => array(
'FIELD_NAME1' => 'RowField 1', 'FIELD_NAME2' => 'RowField 2', 'FIELD_NAME3' => 'RowField 3','FIELD_NAME4' => 'RowField 4',
'FIELD_ID' => 'Row_Id'),
'Row6' => array(
'FIELD_NAME1' => 'RowField 1', 'FIELD_NAME2' => 'RowField 2', 'FIELD_NAME3' => 'RowField 3','FIELD_NAME4' => 'RowField 4',
'FIELD_ID' => 'Row_Id'),
'Row6' => array(
'FIELD_NAME1' => 'RowField 1', 'FIELD_NAME2' => 'RowField 2', 'FIELD_NAME3' => 'RowField 3','FIELD_NAME4' => 'RowField 4',
'FIELD_ID' => 'Row_Id'),
'Row7' => array(
'FIELD_NAME1' => 'RowField 1', 'FIELD_NAME2' => 'RowField 2', 'FIELD_NAME3' => 'RowField 3','FIELD_NAME4' => 'RowField 4',
'FIELD_ID' => 'Row_Id'),
'Row8' => array(
'FIELD_NAME1' => 'RowField 1', 'FIELD_NAME2' => 'RowField 2', 'FIELD_NAME3' => 'RowField 3','FIELD_NAME4' => 'RowField 4',
'FIELD_ID' => 'Row_Id'),
)
);
foreach ($tableData['header'] as $arrayvalue)
{
array_push($tableheader, $arrayvalue);
}
$tmpl = array ( 'table_open' => '<table border="1" cellpadding="2" cellspacing="1" class="gridtable">' );
$this->table->set_template($tmpl);
$this->table->set_empty(" ");
$this->table->set_caption($tableData['tblinfo']['CAPTION']);
$this->table->set_heading($tableheader);
foreach ($tableData['grid'] as $arrayvalue)
{
if (is_array($arrayvalue))
{
//array_walk($arrayvalue, create_function('&$el, $v', 'return $el == "FIELD_ID" ? $v = achor($v, "Edit") : $v; '));
$tablebody[] = array_values($arrayvalue);
}
else { $tablebody[] = $arrayvalue; }
}
echo $this->table->generate($tablebody);
// Create Paging
$paging['base_url'] = $tableData['tblinfo']['BASE_URL'];
$paging['total_rows'] = $tableData['tblinfo']['TOTAL_ROWS'];
$paging['per_page'] = $tableData['tblinfo']['PER_PAGE'];
$this->pagination->initialize($paging);
//print_r($paging);
echo $this->pagination->create_links();
}//endIndex
}
?>
[eluser]Atasa[/eluser]
P.S.
Of course the code is in a controller to run and see the example table.
|