Created
November 11, 2015 16:32
-
-
Save vistajess/c7d50bd9c7308e9c9b4c to your computer and use it in GitHub Desktop.
Data Table
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var MyPurchases = function() { | |
var handlePurchases = function(api,userid,pageNum) { | |
$('#datatable_mypurchase').DataTable({ | |
"ajax": api+"/users/"+userid+"/purchases?page="+pageNum, | |
"columns": [ | |
{ "data": "id" }, | |
{ "data": "net_amount" }, | |
{ "data": "created_at" }, | |
{ "data" : | |
function(data) { | |
var products = data.products.filter(function(item,key){ | |
return item; | |
}); | |
return '<button type="button" \ | |
class="btn btn-primary btn-summary" \ | |
id="order_id'+data.id+'" \ | |
data-toggle="modal" \ | |
data-target="#modal_purchases" \ | |
data-products="'+encodeURIComponent(JSON.stringify(products))+'"> \ | |
Summary \ | |
</button>'; | |
} | |
} | |
], | |
"lengthMenu": [ | |
[15, 20, 50, 100, 150], | |
[15, 20, 50, 100, 150] // change per page values here | |
], | |
"bFilter" : true, | |
"bLengthChange": false | |
}); | |
} | |
return { | |
init: function(api,userid,pageNum) { | |
handlePurchases(api,userid, pageNum); | |
} | |
} | |
}(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment