Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JS table data not captured #30

Closed
umayrh opened this issue Feb 2, 2024 · 1 comment
Closed

JS table data not captured #30

umayrh opened this issue Feb 2, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@umayrh
Copy link

umayrh commented Feb 2, 2024

Hi @OvidijusParsiunas ,

I've a table like so

Screenshot 2024-02-02 at 5 08 18 PM

which, when exported, yields a CSV file (table_data.csv) that doesn't fully represent the data entered in the web component. I see the same problem when I access the table data using the method elementRef.getData(): the data is incomplete.

Any idea why?

Javascript code for table creation:

make_active_table = function(activeTable, tableData) {
    activeTable.data = tableData;
    activeTable.setAttribute(
        "tableStyle",
        JSON.stringify({
            "width":"100%", "boxShadow": "rgb(172 172 172 / 17%) 0px 0.5px 1px 0px", "borderRadius":"2px",
        })
    );
    activeTable.setAttribute(
        "files",
        JSON.stringify({
            "buttons": [
              {
                "import": true,
                "styles": {
                  "default": {
                    "backgroundColor": "#46acff", "height": "19px", "padding": "7px 14px", "color": "white", "border": "unset"
                  },
                  "hover": {"backgroundColor": "#2b9cf8"}, "click": {"backgroundColor": "#198eef"}
                },
                "text": "Import File",
                "position": "top-left",
                "order": 1
              },
              {
                "export": true,
                "styles": {
                  "default": {
                    "backgroundColor": "#46acff", "height": "19px", "padding": "7px 14px", "color": "white", "border": "unset"
                  },
                  "hover": {"backgroundColor": "#2b9cf8"}, "click": {"backgroundColor": "#198eef"}
                },
                "text": "Export File",
                "position": "top-left",
                "order": 0
              }
            ]
        })
    );
    return activeTable;
}

HTML side:

<div id="billTableDiv">
    <active-table id="billTable" headerStyles='{"default":{"backgroundColor": "#d6d6d630"}}'></active-table>
</div>

<button type="submit" class="btn btn-primary" onclick="beforeSubmit();">Save</button>

<script>
function beforeSubmit() {
    const invalidForm = document.querySelector('form:invalid');
    if (!invalidForm) {
        $("#spinner").modal('show');
    }
    activeTable = document.getElementById("billTable");
    document.getElementById("formField").value = JSON.stringify(activeTable.getData());
}
...
setTimeout(() => {
    billTable = make_active_table(document.getElementById("billTable"), {{ bill_table|safe }})
});
</script>
@OvidijusParsiunas
Copy link
Owner

OvidijusParsiunas commented Feb 2, 2024

Hi @umayrh.

Thankyou for raising this issue. There was a bug where upon pasting data into an empty cell did not store it in memory, hence it was not exported. This has now been fixed in version 1.1.4. Please let me know if you see any other issues and I will take care of them as soon as I can. Thankyou!

@OvidijusParsiunas OvidijusParsiunas self-assigned this Feb 2, 2024
@OvidijusParsiunas OvidijusParsiunas added the bug Something isn't working label Feb 2, 2024
@umayrh umayrh closed this as completed Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants