通过jquery,Jquery Datatable版本1.10更新datatable中的单元格

时间:2015-12-15 12:30:23

标签: jquery datatables datatables-1.10

每当Qtde更新时,我都需要更新总量 总值是Qtde和Value的乘法,表是用json

动态加载的

但是我很难拿起aaData的值,我的表格如下:

<!DOCTYPE html>
    <html>
    <head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" charset=utf-8>
    <!-- Bootstrap -->
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet">
    <link href="css/dataTables.bootstrap.min.css" rel="stylesheet">

    </head>
    <body>
    <!-- jQuery (necessario para os plugins Javascript Bootstrap) -->
    <script src="js/jquery.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <script src="js/dataTables.bootstrap.min.js"></script>
    <script src="js/jquery.dataTables.min.js"></script>


        <script> 


            var testeJson = [{"id":"58","country_code":"UK","title":"Legal Director","pubdate":"2012-03-08 00:00:00","value":"1234"},{"id":"59","country_code":"UK","title":"Solutions Architect,","pubdate":"2012-02-23 00:00:00","value":"54343"},{"id":"60","country_code":"UK","title":"Solutions Architect,","pubdate":"2012-02-23 00:00:00","value":"35312"}];
            var Total;

    $(document).ready(function() {
    var OTable = $('#example').dataTable({
        "aaData": testeJson,

        "aoColumns": [ 
            {"sTitle": "select","mDataProp": null, "sDefaultContent": "<input type='checkbox' id ='check01'></input>", "bSortable": false},
            { "mDataProp": "id",sTitle: "id" },
            { "mDataProp": "country_code", sTitle: "country_ ode" },
            { "mDataProp": "title", sTitle: "Titulo" },
            { "mDataProp": "pubdate", sTitle: "Update" },
            { "mDataProp": "value", sTitle: "value" },
            { "mDataProp": null, sTitle: "Qtde", "sDefaultContent": "<input type='text' id='QtdeId' required='required' value='0'/>" },
            { "mDataProp": null, sTitle: "Total", "sDefaultContent": Total }



            ],


    });
        });
        $(document).ready(function() {
        $("#08s")
            .click(function () {

            $(".check01").each(function(){
                    $("check01:checked", table.fnGetNodes()).each(function(){
                        console.log($(this).val());
                    });
                });

            var teste = OTable.fnGetData();

        alert(JSON.stringify(teste));

        });

        });
            }

    $(document).ready(function() {
       $('#example1').DataTable( {
            data: dataSet,
            columns: [

                { title: "Id" },
                { title: "Nome do Produto" },
                { title: "Unidade" },
                { title: "Preço Unitário" },
                { title: "Qtde" },
                {title: "Total"}

            ]
        });

    } );
            function teste(OTable){
                var teste = OTable.fnGetData();
        alert(teste.id);    
            }

            $(document).ready(function() {    
        $(":checkbox").click(function(){
            var id = $(this).attr('check01');

        });    
    });
        </script>
    <table id="example" class="table table-striped table-bordered" cellspacing="1" width="70%">
    <input type="button" name="botao-ok" value="Ok" id="08s">

0 个答案:

没有答案