lc-soft / LCUI

C library for building user interfaces
https://lcui-dev.github.io
MIT License
4.14k stars 357 forks source link

DataTable #203

Closed bencz closed 4 years ago

bencz commented 4 years ago

I would like to know about the implementation of DataTable, with filters per column, checkbox column and etc ..., how to get the selected rows on datatable with checkbox..... From what I looked for, there is still no implementation in the system for that

lc-soft commented 4 years ago

I would like to know about the implementation of DataTable, with filters per column, checkbox column and etc

Does the DataTable you mean look like this?

image

DataTable requires the support of a new layout system to implement it, but this feature is not included in the development plan of this project, so please check out other similar projects.

how to get the selected rows on datatable with checkbox

As far as I know, there are two solutions:

  1. Add an event binding for each checkbox in the DataTable, and when the checked event is triggered,, mark the bound data row as checked.
  2. When you need to submit data, iterate through each row in the DataTable. If the checkbox of the row is checked, the data of the row is recorded. The pseudo code is as follows:

    function getSelectedRows(table:DataTable, yourData:Array):Array {
        const selectedRows:Array = [];
    
        table.children.forEach((row, index) => {
            if (row.querySelector('checkbox').checked) {
                selectedRows.push(yourData[index]);
            }
        })
        return selectedRows;
    }
bencz commented 4 years ago

Good morning, from Brazil! Thanks for your response. Yes, when I asked about the datatable, it was just that type Well, no problem .... I saw that you also do sponsored development, how much would it be necessary for you to develop data-table support?

When I asked about getting data from the data-table, it would be using your lib!

lc-soft commented 4 years ago

I saw that you also do sponsored development, how much would it be necessary for you to develop data-table support?

I do n’t have time to develop complex new features now and in the next few months. Sponsored development will make me feel pressured. I just want to make my life easier, so please let me reject your request.

bencz commented 4 years ago

Oh, ok!! No problem, you are right! :) Thank you!!