[eluser]Unknown[/eluser]
I am use flexigrid
controller
Code: function dicgrid1()
{
$colModelMaster['value'] = array('nama',200,TRUE,'left',2,0);
$colModelMaster['Descritption'] = array('description',100,TRUE,'left',1,0);
$colModelMaster['actions'] = array('action',80, TRUE, 'right',0,1);
$buttons[] = array('Add','add','[b]dic1[/b]');
$buttons[] = array('Delete','delete','[b]dic1[/b]');
$buttons[] = array('Edit','edit','[b]dic1[/b]');
$gridMasterParams = array(
'width' => '440',
'height' => 200,
'rp' => 15,
'rpOptions' => '[10,15,20,25,40]',
'pagestat' => 'Displaying: {from} to {to} of {total} items.',
'blockOpacity' => 0.5,
'title' => $tablename,
'showTableToggleBtn' => true,
'singleSelect'=>true
);
$griddictionary_js =
...
}
function dicgrid2()
{
$colModelMaster['value'] = array('nama',200,TRUE,'left',2,0);
$colModelMaster['Descritption'] = array('description',100,TRUE,'left',1,0);
$colModelMaster['actions'] = array('action',80, TRUE, 'right',0,1);
$buttons[] = array('Add','add','[b]dic2[/b]');
$buttons[] = array('Delete','delete','[b]dic2[/b]');
$buttons[] = array('Edit','edit','[b]dic2[/b]');
$gridMasterParams = array(
'width' => '440',
'height' => 200,
'rp' => 15,
'rpOptions' => '[10,15,20,25,40]',
'pagestat' => 'Displaying: {from} to {to} of {total} items.',
'blockOpacity' => 0.5,
'title' => $tablename,
'showTableToggleBtn' => true,
'singleSelect'=>true
);
$griddictionary_js =
...
}
view
Code: function dic1(com,grid)
{
if(com=='Add'){
$("#dialog").dialog({
position:["center","center"],
modal:true
}
);
$('#country_frm').load('<?php echo site_url('/ajax/add_dic/[b]func1()[/b]'); ?>');
}
}
function dic2(com,grid)
{
if(com=='Add'){
$("#dialog").dialog({
position:["center","center"],
modal:true
}
);
$('#country_frm').load('<?php echo site_url('/ajax/add_dic/[b]func2()[/b]'); ?>');
}
}
[eluser]CroNiX[/eluser]
Is there a question in there somewhere?
[eluser]Xclamation Design[/eluser]
[quote author="CroNiX" date="1311308413"]Is there a question in there somewhere?[/quote]
I think it's in the subject... 'How to refactor code?'
[eluser]toopay[/eluser]
For above code, just declare a multidimensional array variable on class scope, so that it reusable and you didnt need to declare it everywhere in your function.
|