Check if the childrow is empty or not before opening it

Check if the childrow is empty or not before opening it

FrankLar21FrankLar21 Posts: 2Questions: 1Answers: 0

I am a new developer and want to make a jquery datatable. In this table I want to display the names of the schools and in child row I want to display the name of the programs of this school. For the moment all is well, but I want to make a 2nd child row which will allow me to display the groups of these programs in a mini "profile" section. I wanted to know if there is a way to check if the program has groups before clicking on the icon that displays the child row, so at the same time put a callsign that will tell me that the program does not contain any groups.

I proceed step by step to make my calls. First, when I get to the page I display the schools that are linked to the current user. Second, when the person clicks on the + of this school, I make another call which makes me display the programs in a table in the child row.

Maybe I'm the one doing it wrong, but no matter where I go I get lost.

I had thought to make my call for groups of groups in the :

                    data: null,
                    title: '<thead><tr role="row"><th class="details-control dt-center sorting_disabled" rowspan="1" colspan="1" aria-label="" style="width: 64px;">Code</th><th class="sorting" tabindex="0" rowspan="1" colspan="1" aria-label="Training centre: activate to sort column ascending" style="width: 1142px;">Nom programme</th><th class="dt-center sorting_disabled" rowspan="1" colspan="1" aria-label="Action" style="width: 188px;">Actions</th></tr></thead>',
                    render: function (data, type, row, meta) {
                        var response = "";
                        $.get("@Html.Raw(Url.Action("Test", "Publicite"))?EcoleCode=" + rowData.ecoleCode + "&progCode=" + row?.FK_programme + "", function (res) {

                            if (res.length > 0) {
                                dataExist = true;
                                response = res;
                            }


                        });

                        var icon = '<i data-details="' + response +'" data-prognom="' + row.PROG_NOM + '" data-progid="' + row.FK_programme + '" data-centreid="' + rowData.ecoleCode + '" data-instid="' + row.FK_etablissement + '" style="color:#009c9f;" class="fa fa-arrow-circle-down secondChild-details-control dt-center"></i>';

                        return '<tbody><tr role="row"><td class="dt-center" rowspan="1" colspan="1" aria-label="" style="width: 64px;">' + row?.FK_programme + '</td><td tabindex="0" rowspan="1" colspan="1" style="width: 1142px;">' + row?.PROG_NOM + '</td><td class="dt-center" rowspan="1" colspan="1" aria-label="Action" style="width: 188px;">' + icon + '</td></tr></tbody>';

                    },
                    targets: "no-sort",
                    orderable: false

but in this case I should make the 1st child row display in a single render column and do the html in this one and I have a problem in this call. If anyone has a better approach I'm a taker (don't look at the css and the design, nothing gets done)

Here is a photo of a program with no groups

Here is a photo of a program with groups

and here is a preview of the profile view I want to give

Answers

  • kthorngrenkthorngren Posts: 21,341Questions: 26Answers: 4,954

    Take a look at this example of removing the plus sign if the child has no records. Maybe it will give you some ideas of what you can do:
    http://live.datatables.net/pifugoki/115/edit

    Sounds like you have a lot going on. Please post a link to your page or a test case replicating the issue so we can take a look and offer suggestions.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • FrankLar21FrankLar21 Posts: 2Questions: 1Answers: 0

    UPDATE:

    After rethinking my business with a clear head, I found a solution. I modified my request which displays the programs by adding a Select Count for a field which will allow me to know the number of groups contained in the program. I was looking way too far. Here is the request

    SELECT *, (SELECT COUNT(OS.id) FROM tbl_offreSec OS WHERE OS.FK_ecole = ESA.FK_ecole AND OS.FK_programme = ESA.FK_programme AND OS.archive = 0) AS nbGroupeActif
    FROM tbl_ecoleSecAuth ESA
    INNER JOIN PROG_SEC ON PROG_SEC.PROG_CODE = ESA.FK_programme
    WHERE FK_ecole = " + code + "
    ORDER BY PROG_SEC.PROG_NOM

This discussion has been closed.