This is my very first jquery plugin so be gentle!
My requirments
<script src="/mrjsontable/scripts/mrjsontable.js"></script>
<link href="/mrjsontable/css/mrjsontable.css" rel="stylesheet" />
<div id="mydiv"></div>
Information on columns can be passed using a standard json object or a $.fn.mrjsontablecolumn({}); object. both version are used below
<div id="mydiv"></div>
<script>
$(function () {
$("#mydiv").mrjsontable({
columns: [
{
heading: "Can be any text for the heading of this column",
data: "json_data_field_name", // see how this links to the json object further down
type: "string", // can be string, int, float, datetime
sortable: true, // is the field sortable (optional defaults to false)
starthidden: true // should the field be hidden when loaded (optional defaults to false)
},
new $.fn.mrjsontablecolumn({
heading: "Name",
data: "name"
}),
{
heading: "Another heading",
// etc...
}
],
data: [
{
yourdata: yourvalue,
json_data_field_name: value //in this example the first column is looking for this field specified in the data property,
name: name_value // in this example the second column is looking for this value
},
{
yourdata: yourvalue,
// etc...
}
]
});
});
</script>
As always, if you have any questions or queries then feel free to ask someone else first :D
A big thanks to SyntaxHighlighter 3.0.83 for making my code look pretty
If you feel the urge to buy me a beer or follow me on twitter here are some buttons!
Follow @Matching_Radar