• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
delete table row without refresh page

#1
[eluser]teddy[/eluser]
I used library table of codeigniter and below is my code, but I I don't know how to delete row without refresh page, someone tell me a links tutorials or guide how to do it.

Quote: function products_list($offset=0)
{


// offset
$uri_segment = 3;
$offset = $this->uri->segment($uri_segment);

//load data
$this->load->model('products_model');
$list=$this->products_model->getPagedList($this->limit,$offset)->result();
// generate pagination
$this->load->library('pagination');
$this->load->library('table');

$config['base_url']=site_url('products/products_list');

$config['total_rows']=$this->db->get('tbl_products')->num_rows();
$config['per_page']=$this->limit;
$config['num_links']=20;
$config['uri_segment']=$uri_segment;
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();

$this->table->set_empty(" ");
$tmpl=array('table_open' => '<table border="0" cellpadding="2" cellspacing="1" class="table_product">');
$this->table->set_template($tmpl);


$this->table->set_heading('No', 'Product name', 'Product cate', 'Price', 'Actions');

$i=0+$offset;
foreach($list as $l)
{

$this->table->add_row(++$i,$l->name,$l->cateid,$l->price,
anchor('products/products_list/view/'.$l->id,'view',array('class'=>'view')).' '.
anchor('products/products_list/update/'.$l->id,'update',array('class'=>'update')).' '.
anchor('products/delete/'.$l->id,'delete'
,array('class'=>'delete','onclick'=>"return confirm('Are you sure want to delete this person?')"))
) ;

}

$data['table']=$this->table->generate();

$this->load->view('products_list',$data);
}


function delete($id)
{
$this->load->model('products_model');
$this->products_model->delete($id);
redirect('products/products_list/','refresh');
}

Thank you for reading my topic.


#2
[eluser]Christer_[/eluser]
Google up AJAX and PHP - Im sorry i cant give any detailed explanations right now - but im just about finished from work so its a last minute forum check Tongue

But that should atleast give you a clue.

#3
[eluser]kanjimaster[/eluser]
It's not clear wholly clear what you're wanting to achieve here. Is it to delete the table row but leave it displayed on the page anyway, or is it to avoid the overhead of refreshing the entire page? i.e. why don't you want to refresh the page?

In both cases solution is likely to involve some use of AJAX, but the possible solutions would depend on which javascript library you are using. In the latter you'd also need to make sure that your table building code is available to both the regular and ajax controller methods.

#4
[eluser]teddy[/eluser]
Quote:Is it to delete the table row but leave it displayed on the page anyway, or is it to avoid the overhead of refreshing the entire page? i.e. why don’t you want to refresh the page?

Delete the table row is very useful, example when you view page 2 and want delete any table row you don't have to load the page with start page 1, and the screen is smooth than load all data of the page.

somebody help me, please. Thanks.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.