⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Showing progress in popup window and refreshing page once it's done



Nitin Thokare
  • profile picture
  • Member

Posted 05 June 2014 - 06:39 AM

When I'm adding new data in list, it's showing 'Loading, saving data...' , with all buttons (Save, Save and go back to list, Cancel) active. Which is general behavior.

 

This continues to show even when data has been added to tables (I can see data has been updated in mysql). Page is not getting refreshed after adding. Same is happening when I delete the row (in list). Page is not getting refreshed after delete.

 

My controller is as below:

 

function view_company(){
  $crud = new grocery_CRUD();
  $crud->set_table('company');
  $crud->set_subject('Company');

  /*column in displayed table and fields to view/add/edit */
  $crud->columns('Id','Name','Email','Address','LogoURL');
  $crud->fields('Name','Description','Email','Address','LogoURL');
  $crud->display_as('LogoURL','Logo');

  /*required field in add/edit*/
  $crud->required_fields('Name','Address');
  $crud->set_field_upload('LogoURL','images');
  $crud->unique_fields('Name','Email');

  $crud->callback_after_insert(array($this,'create_company_db'));
  $crud->callback_after_delete(array($this,'delete_company_db'));

  $output = $crud->render();
  $this->load->view('admin/view/company',$output);
}

function create_company_db($post_array, $primary_key){
  if(empty($primary_key)){
    return false;
  }
  $this->load->model('model_db_init');
  $newdbname = "company_".$primary_key."_db";
  $this->model_db_init->dbInitialize($newdbname);
  return true;
}

function delete_company_db($primary_key){
  if(empty($primary_key)){
    return false;
  }
  $newdbname = "company_".$primary_key."_db";

  $this->load->model('model_db_init');
  $db_deleted = $this->model_db_init->dbDeleteDB($newdbname);

  $this->load->model('model_admin');
  $com = $this->model_admin->get_company_by_id($primary_key);
  $com = $com->row();
  $img = $com['LogoURL'];
  $url= 'images/'.$com->LogoURL;
  chmod($url, 0777);
  unlink($url);

  /* redirect('settings_admin/view_company','refresh'); */
  return $db_deleted;
}

I tried using, redirect('settings_admin/view_company','refresh'); , but still it's not refreshing the page.

 

Also i want to display progress bar (message  'Loading, saving data...) in popup window so that user should not click on any button till the process is not finished.. How to do it?

 

Also there is issue in deleting file by unlink(). It's not deleting the file at given path.

 

In all there are three issues in above code:

1) Page is not getting refreshed after add/edit/update the data..

2) File is not getting deleted using unlink() and

3) How to display progress bar (message  'Loading, saving data...) in popup window so that users will not click any button during add/update/delete operation?

 

Can anybody help me to resolve these issues?

 

 


Amit Shah
  • profile picture
  • Member

Posted 05 June 2014 - 20:08 PM

This is only possible when there is an error generated or text other then the desired json is generated as an output..

Do check up the output of the call in firebug - it will help u understand better as where and why things are going wrong.. fix those and the system will be rocking all again,.

 

Happy CGing:)


sknevhal
  • profile picture
  • Member

Posted 21 April 2015 - 10:42 AM

How to send and retrieve data to pop up window (I am using in my form AJAX, groceryCrud, PHP,Jquery, Javascript, codeIgniter etc.)

Without pop up window, data can be transferred by using AJAX on the same form without submitting it. But is it possible to use AJAX on pop up window? If yes then how?Otherwise any other solution will also do. Thanks in advance!


Amit Shah
  • profile picture
  • Member

Posted 25 April 2015 - 04:03 AM

sorry  - could not understand what u exactly need from the statement - i failed to understand.. if u can assist what you need in simpler terms.. like steps or so - and where u getting stuck up... may be it will make it simpler to reach out to a solution


Nitin Thokare
  • profile picture
  • Member

Posted 08 May 2015 - 12:08 PM

In grocery_crud.php (configuration) file, if  $config['grocery_crud_dialog_forms']=true , the add/edit/view form are shown as popup windows. In my case, I have few field on form which uses AJAX for populating those fields.  When above flag is set to "false", these forms works with AJAX as expected. But when it is set to "true", the AJAX operations do not work. Is there any solution to this  problem?


sknevhal
  • profile picture
  • Member

Posted 14 May 2015 - 10:01 AM

Amit Shah:

sorry  - could not understand what u exactly need from the statement - i failed to understand.. if u can assist what you need in simpler terms.. like steps or so - and where u getting stuck up... may be it will make it simpler to reach out to a solution

 

sknevhal:

Amit Sir,

I have found the way (i.e. Ajax and jQuery is working on Pop up window now. I have used fancybox. )..Yet I have some issues with fancybox. (i.e. it is working in some function in grocery CRUD.and in some other function it is not working. I am using fancybox for add_actions in grocery CRUD. It is working with add,edit and delete actions on pop up window now. In Some other form/function it just don't pop up at all.). I am trying to find solution to the problem.If you know the solution or probable reasons you may please tell me.

Sorry for my English!

Thanks!