⚠ 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

Exporting issues (related and date fields)



wgh000
  • profile picture
  • Member

Posted 06 May 2013 - 15:21 PM

As per title, I need to export for excel all the records of the view with the original values because the same data will be reused in a second time.

 

Actually the issue is

• fields related to another table show in the exported XLS/CSV the linked field and not the original "id"

• date fields are also converted as seen in the web view, but I need to export them in db format YYYY-MM-DD

 

Can you help me?


davidoster
  • profile picture
  • Member

Posted 07 May 2013 - 09:07 AM

1. make another controller function that doesn't have the set_relation (s) functions. this way you will see the actual id (or just change to id instead of a name/description)

2. go to application\config\grocery_crud.php there you will find your answer


wgh000
  • profile picture
  • Member

Posted 08 May 2013 - 13:48 PM

Thanks davidoster, but ... ok, I know that I can have a different controller with different configurations, but how can I export, from the "wrong view" the data taken from a 2nd controller?

 

Also, I changed the date format in SQL mode, but when I open the export in Excel, it convert it as a date (doing what it wants!)

 

Can you give me more details?


davidoster
  • profile picture
  • Member

Posted 08 May 2013 - 21:09 PM

You load->view as before.

You just omit the set_relation functions.

If you don't mean that then you need to give us a screen capture in order to understand.


wgh000
  • profile picture
  • Member

Posted 10 May 2013 - 12:34 PM

I think I could not explain well the issue. Let's try again.

 

I've got a view where I show a Grocery CRUD that need to have the set_relation active because help valorize some of the fields of the form. Let's say

----------------------------
| id | id_store | my_value |
----------------------------

The ID is hidden, ID_STORE is the field with relation setted to the store table. In this way, while adding / editing, is quite easy choosing the right "id" selecting the store from a dropdown menu.

 

When I export this data, I need to export the original ID_STORE and not the name, because I need to "upload" this csv / xls in a different web app. Actually, the system is exporting not the ID_STORE, but the related "view" for the relation (STORE_NAME). I need to export the ID_STORE field, like when you do a "dump" of the mySQL related table.

 

I actually download

------------------------------------------------
| 1 | san francisco store 1 | text valorized 1 |
------------------------------------------------
| 1 | san francisco store 2 | text valorized 2 |
------------------------------------------------
| 1 | chicago store 1       | text valorized 3 |
------------------------------------------------

 

but I would like to download

----------------------------
| 1 | 1 | text valorized 1 |
----------------------------
| 1 | 2 | text valorized 2 |
----------------------------
| 1 | 3 | text valorized 3 |
----------------------------

 

 

I hope I've been more clear now.

Thanks a lot.


davidoster
  • profile picture
  • Member

Posted 11 May 2013 - 09:50 AM

If that's the case..., then explain to me how this happens,

http://eletter.gr/temp/gc1_4/index.php/test/a


davidoster
  • profile picture
  • Member

Posted 12 May 2013 - 05:48 AM

Well, my sincere apologies!!!

I thought that whatever you see on the screen, it prints also!

I will check again the library code and I will propose a solution.

 

P.S. That's why they say, as long you live you learn.


davidoster
  • profile picture
  • Member

Posted 13 May 2013 - 09:59 AM

I was investigating today about the export (and print operations).

At first I thought that it reads the table, checks for foreign keys and/or relations and callbacks and traces back the actual value.

But it is actually much simpler than that.

When a grid is displayed all the values are stored in memory.

So, if you just display the grid you want, without any relations, just like this the export function does work as I first suspected it would!


wgh000
  • profile picture
  • Member

Posted 13 May 2013 - 16:57 PM

Yes, of course. Grocery print what it shows on the screen, but I don't need that! I need to have a simplest way to manage data by the users and a confortable way to manage data offline.

Do you agree with me that it's easier to choose an ID using a "dropdown menu" instead of find the related value in a table and copy the ID?

 

I think Grocery should have a "double" option to choose if export the view or the raw data...

 

I need the raw data, now...


davidoster
  • profile picture
  • Member

Posted 13 May 2013 - 17:16 PM

Your very first (initial) question was answered here and here.

What you ask on this should be posted as a new topic where you need to explain again what you need.

 

P.S. 1: Bear in mind that what might seems easier to you might not be easier (or the best way) for the others.

P.S. 2: Grocery CRUD is based on the initial effort of one person and on the contributions of others. Why don't you build this "double" option feature so we can all benefit from it? If you try it, remember to follow the guidelines on how to extend the library.  :)