datatable data recovery

datatable data recovery

aboubakraboubakr Posts: 1Questions: 0Answers: 0
edited January 2020 in Free community support

Hi, I'm a beginner so tried to understand myself.
I have a datatable with data I would like to recover all of them and save them in my comic strip when I press on pon button to validate with jquery.

<script>
$(document).ready(function() {
    $("#btn").click(function() {
        
        var data = mytabe.rows().data();
        
            $.post("<?php echo base_url()?>pointage/SavePointage", {
                idagent: $("#idagent").val(),
                datejr: $("#datejr").val(),
                heurdebut: $("#heurdebut").val(),
                heurefin: $("#heurefin").val(),
                observation: $("#observation").val()
                },
                function(data, status) {
                    alert("Data: " + data + "\nStatus: " + status);
                });
        });
});
</script>

<div class="data-table-area mg-b-15">
    <div class="container-fluid">
        <div class="row">
            <form method="post" name="frm-example" id="frm-example">
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <div class="sparkline13-list">
                    <div class="sparkline13-hd">
                    </div>
                    <div class="card-header py-3">
                        <button type="submit" id="btn" class="btn btn-primary pull-right">enregistrer</button>

                    </div>
                    <div class="sparkline13-graph">
                        <div class="datatable-dashv1-list custom-datatable-overright">

                            <table id="mytabe" name="mytabe" class="table table-striped ">
                                <thead>
                                    <tr>
                                        <th data-field="matricule">Matricule</th>
                                        <th data-field="nom">Prénom et Nom</th>
                                        <th data-field="datejr">Date Présence</th>
                                        <th data-field="heurdebut">Heure D'arrivée</th>
                                        <th data-field="heurefin">Heure Départ</th>
                                        <th data-field="observation">Observation</th>
                                        <th data-field="action">Action</th>
                                    </tr>
                                </thead>
                                <tbody>

                                    <?php if(isset($getall)):?>
                                    <?php foreach($getall as $getel): ?>
                                    <tr>
                                        <td>
                                            <?php echo $getel->matricule?>
                                        </td>
                                        <td>
                                            <?php echo $getel->nom?>
                                            <?php echo $getel->prenom?>
                                        </td>

                                        <td>
                                            <input type="text" class="form-control" name="datejr" id="datejr"
                                                value="<?php echo date("d/m/Y",strtotime("yesterday")); ?>" readonly />
                                        </td>

                                        <td>
                                            <input type="time" class="form-control" name="heurdebut" id="heurdebut" />
                                        </td>
                                        <td>
                                            <input type="time" class="form-control" name="heurefin"  id="heurefin"/>
                                        </td>
                                        <td>
                                            <input type="text" class="form-control" name="observation" id="observation" />

                                        </td>
                                    </tr>
                                    <input type="hidden" name="idagent" id="idagent" value="<?php echo $getel->id; ?>" />
                                    <input type="hidden" name="hidden_id" value="<?php echo $getel->id; ?>" />
                                    <?php endforeach;?>
                                    <?php else: ?>
                                    <tr>
                                        <td>Pas d'enregistrement ... </td>
                                    </tr>
                                    <?php endif;?>
                                    <!-- fin code tableau dynamique -->
                                </tbody>

                            </table>
                        </div>
                    </div>
                </div>
</form>
            </div>
        </div>
    </div>

Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Replies

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    I'm not clear what you're trying to do.

    You're accessing the table here:

            var data = mytabe.rows().data();
    

    but I can't see where you're initialising the table to begin with. It would be worth reading the manual to ensure you're initialising the table correctly.

    Colin

This discussion has been closed.