Comments (15)
I think I understand, what you want is to configure what is overwritten.
I can investigate the creation of the following options:
- overwrite all content (default)
- overwrite data only
- append data only
The risk for the last two is that the user may change the headers or create/remove columns so the imported CSV's data may no longer adhere to the correct columns. When using these options we need to trust the developer to configure the table properties to not allow the header to be changed with the use of isHeaderTextEditable
and others.
This feature's implementation will take a little more time as different developers may configure the active table differently and I need to make sure this feature will work correctly for all cases. Due to the fact that I am working on multiple projects I can likely have a working prototype for this by tomorrow (similar time), but I will keep you posted on any progress.
Let me know what you think about these options.
from active-table.
Hi!
Thank you so much for implementing the features that I requested. I really appreciate your quick and efficient work. You have done a great job and I'm very happy with the result.
from active-table.
Seems like working now :) Thanks you again!
from active-table.
Hi @sbachiller, thankyou very much for raising this ticket.
For the first issue, I can definitely add a property that would allow you to specify what the output file name should be.
For the second issue, could you elaborate on what you mean by the headers not being maintained when you import a csv? I also did some investigation and found that the () => ColumnsDetails type for importCSV in the documentation is INCORRECT and the function is not supposed to return anything. May I ask a little bit more about your usecase to see if I can provide guidance on how you can achieve what you want using the existing API or if I need to add something to the code. Thanks!
from active-table.
In the meanwhile I am going to start working on the first issue, update the documentation and keep you updated on the progress.
from active-table.
I have just published version 0.0217 for the active-table npm package where you can specify the exported file's name when calling the exportCSV
method. E.g:
tableRef.exportCSV("customName");
or tableRef.exportCSV("customName.csv")
.
If you are using the csvButtons property to export your file via prebuilt buttons - you can specify the file name as follows:
<active-table csvButtons='{"export": {"fileName": "customName"}}'></active-table>
This is a csvButtons JavaScript example and you can tailor it your framework as needed. Also, because csvButtons is an attribute/property - the fileName
property for it cannot be changed after the table has been rendered. If you need the file name to change during application runtime - you will need to create your own button in your app that would call the exportCSV
method on the table element ref (1st example) when clicked.
from active-table.
Hopefully the above takes care of the first issue, I will keep this thread open to get a bit more clarification on the second issue. Thanks!
from active-table.
Hello!
Thank you very much for the quick update of the library. What I mean in the second item is that currently the first row of the content is used as the header of the table, and when you import a file the headers are overwritten as well. In my case, I would like to keep fixed headers for the user to enter only the data, so that when importing, only the file with content has to be added, as the headers already exist.
Also, I propose that when importing from a file there is the option to overwrite all the content or add it at the end, what do you think? :)
Again, thank you very much
from active-table.
Hi, just an update, I am working on this and am currently ironing out a variety of edge cases that can cause errors. I will update this very shortly on how to use the new API.
from active-table.
I have released the new functionality on package version 0.0.221. I am going to update the documentation (as well as the React package) for it tomorrow as it needs to be done in a comprehensive manner.
Here is how to use it:
When passing the options object inside the importCSV
method or when using the import
property in csvButtons
, you can now add an additional property called overwriteOptions
. This property is an object that has the following type:
{tableRowStartIndex?: number; csvRowStartIndex?: number}
Both of these properties use zero index based numbers (they start with 0).
tableRowStartIndex
is the starting row at where you want the imported data to start overwriting the table rows. So if you don't want to overwrite the header and start from the second row, set it to 1
. The default value for this is 0
- meaning that the imported data will start overwriting at the start. You can additionally set this value to -1
which will append the data after the last row of the table.
csvRowStartIndex
is the starting row for the imported CSV data. So if you want to ignore the header, set it to 1
.
Here is an example on how to use it with the importCSV
method:
tableRef.importCSV({tableRowStartIndex: 1, csvRowStartIndex: 1});
Here is an example on how to use it with csvButtons
property:
<active-table csvButtons='{"import": {"overwriteOptions": {"tableRowStartIndex": 1, "csvRowStartIndex": 1} } }'></active-table>
(Please tailor the above example to your framework)
Let me know if you have any questions or encounter any issues. Thankyou!
from active-table.
Hello again!
I am trying this new functionality and I think I found a bug while importing; seems like the last column of the file is missing on the table. I have been debugging the module and find out this is happening in insertMatrix.js:118 as I have isInsertRightAvailable on my table turned off. This makes indexOfNoRightInsertionColumn become -1 and slice the last value for each row.
Changing isInsertRightAvailable to true makes it work, but I don't want the user to be able to add columns :(
Thanks in advance :)
from active-table.
Hi @sbachiller, thanks for raising this issue! I think I can replicate this problem, but I want to make sure I found the same bug as you. Could you share the code you are using to configure the table? (No need to share any of your data, just the table configuration)
from active-table.
The root of the problem lies in the fact that I made the import CSV functionality work like copy/paste CSV data functionality, meaning that columns that have isInsertRightAvailable
set to false
will not allow any new data to be inserted on the right - which makes sense in the context of pasting data, but does not when importing.
There are use-cases where we don't want to amend right side columns of ones with isInsertRightAvailable
with false
, even on import, hence I will add another option inside the overwriteOptions
object to toggle this. Stay tuned, and I will update you on its progress.
from active-table.
Allowing the user to toggle the column overwrite behaviour just causes more problems, I will instead simply let the import CSV functionality ignore the isInsertRightAvailable
and overwrite the data.
This is available in version 0.0.222 of the npm package. Please let me know if this fixes your problem :)
from active-table.
Please note that the properties used for the configuration of the example above adhere to active-table version that is earlier than 0.2.3 which may differ to the latest version of the component. Please check the documentation to make sure you are using the correct properties or directly refer to our examples.
from active-table.
Related Issues (20)
- Is it possible to translate the table elements? HOT 2
- Searching select box HOT 1
- any interface to change ui label in another language HOT 3
- Cannot get basic example running HOT 12
- Using active-table in a Flask app HOT 3
- CSV import doesn't support escaped commas HOT 1
- JS table data not captured HOT 1
- Cannot find module error while compiling HOT 6
- how to sponsor HOT 2
- Embedding custom HTML inside table cells HOT 2
- Provide display options for columnType HOT 6
- not explaining the usage process HOT 4
- 'cell-update' event seems to return wrong details
- navigator is not defined when using with NextJs HOT 5
- Table becomes laggy when displaying a long table HOT 1
- ERROR: ResizeObserver loop completed with undelivered notifications.
- Restoring table with column types HOT 5
- CSV export is missing formatting options to be useful
- Improvement Suggestion: Change Cursor Type for Non-Editable Select Cells
- Custom buttons
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from active-table.