Welcome Guest, Not a member yet? Register   Sign In
Flexigrid: Add Records
#1

[eluser]meetsang[/eluser]
Hi,

I am new to PHP and happened to find codeigniter and flexigrid for my first project. I implemented the flexigrid and want to know if I can make "ADD" button functional. I have tried very hard to do that but not sure how to bring a popup with the desired fields and then validate them. If anyone has achieved this functionality or a workaround please help me. I hope somebody has good solution for this. I read a lot about flexigrid in the forums but no where I could find a good code for adding records.

Also, since this is not working I am planning to switch to another datagrid. I found that rapyd (http://codeigniter.com/wiki/Rapyd_Components/) has good components for data grid and other components too. Please let me know if this is the best tool for adding, editing, viewing and deleting records.

Thanks.
Sang
#2

[eluser]Nicolas400[/eluser]
First of all, Sorry for the expectation of the answer.
I'm looking for the same.

I'm trying rightnow a combination of Flexigrid and CodeCrafter, since teh last one has teh ability to develop the CRUD that I need.

Also try ThickBox but I lost the fight.

Regards
#3

[eluser]Crafter[/eluser]
meetsang

Nobody can tell you what the best tool is, but there are are number of items.

I'm sure if you look around, you'll find flexigrid is able to fire an event where you can pop up a form. Unfortunately, I've not used flexigrid, but I have used YUI and I see it is the same, conceptually.

I've changed my CodeCrafter templates to generate JSON, instead of HTML when a listing is requested. The Javascript code therefore loads the grid, sends a request, gets back the JSON and loads the data into the grid.

Then, when a 'click' event is fired, I send the form in HTML mode, which I draw in a "popup" dialogue.
#4

[eluser]imtiazhashmi[/eluser]
hii,
can u post that code.
im also using json and trying to achieve same.
thanx in advance
#5

[eluser]Unknown[/eluser]
function actionUser(com,grid)
{
if (com=='Select All')
{
$('#country_list tbody tr',grid).addClass('trSelected');
//$('.bDiv tbody tr',grid).addClass('trSelected1');

}
if (com=='Clear All')
{
$('#country_list tbody tr',grid).removeClass('trSelected');

}
if(com=='Add'){

$("#loading").dialog("open");
$('#country_list_div').css('display','none');
$('#country_frm').load('<?php echo site_url('/country/form/'); ?>');

}

}

//form.php in views
<h3 class="title_black">&lt;?php echo $this->lang->line('country_form'); ?&gt;</h3>

&lt;?php $this->load->view('dashboard/system_messages'); ?&gt;

<div class="content toggle">
&lt;form id="frm" method="post" action="&lt;?php echo site_url($this-&gt;uri->uri_string()); ?&gt;" onsubmit="return submitForm('&lt;?php echo uri_assoc('id')?&gt;')">
&lt;!--<p id="error" class="addTips">* Fields are mendatory</p>--&gt;
<table width="100%" align="center" class="formtable">
<tbody>
<tr>
<td width="50%"><label>&lt;?php echo $this->lang->line('name'); ?&gt;</label>&lt;input type="text" name="name" id="name" class="text ui-widget-content ui-corner-all" value="&lt;?php echo $this-&gt;form_model->name; ?&gt;" /></td>
<td width="50%"><label>ISO:</label>&lt;input type="text" name="iso" id="iso" class="text ui-widget-content ui-corner-all" value="&lt;?php echo $this-&gt;form_model->iso; ?&gt;"/>
</td>
</tr>
<tr>
<td><label>Printable Name</label>&lt;input type="text" name="printable_name" id="printable_name" class="text ui-widget-content ui-corner-all" value="&lt;?php echo $this-&gt;form_model->printable_name; ?&gt;"/></td>
<td><label>ISO 3</label>&lt;input type="text" name="iso3" id="iso3" class="text ui-widget-content ui-corner-all" value="&lt;?php echo $this-&gt;form_model->iso3; ?&gt;"/>
</td>
</tr>
<tr>
<td><label>Number Code</label>&lt;input type="text" name="numcode" id="numcode" class="text ui-widget-content ui-corner-all" value="&lt;?php echo $this-&gt;form_model->numcode; ?&gt;"/></td>
<td></td>
</tr>
<tr>
<td align="center" colspan="2">
&lt;input type="submit" id="btn_submit" value="&lt;?php echo $this-&gt;lang->line('submit'); ?&gt;" name="btn_submit"/>
&nbsp;&nbsp;
&lt;input type="button" id="btn_cancel"&gt;lang->line('cancel'); ?&gt;" /></td>
</tr>

</tbody>
</table>



&lt;/form&gt;

</div>
//add function in country class
function form() {

if (!$this->form_model->validate()) {

$this->load->helper('form');

if (!$_POST AND uri_assoc('id')) {

$this->form_model->prep_validation(uri_assoc('id'));

}
$this->load->view('form');

}

else {

$this->form_model->save($this->form_model->db_array(), uri_assoc('id'));

}

}

//add this in model
public function validate() {

//all fields add, update
$this->form_validation->set_rules('name', $this->lang->line('name'), 'required');
$this->form_validation->set_rules('iso', "ISO");
$this->form_validation->set_rules('iso3', "ISO 3");
$this->form_validation->set_rules('printable_name', "Printable Name");
$this->form_validation->set_rules('numcode', "Number Code");
return parent::validate();

}




Theme © iAndrew 2016 - Forum software by © MyBB