Skip to content

Instantly share code, notes, and snippets.

@dshook
Last active August 29, 2015 14:07
Show Gist options
  • Select an option

  • Save dshook/124d9548271f60d67ac6 to your computer and use it in GitHub Desktop.

Select an option

Save dshook/124d9548271f60d67ac6 to your computer and use it in GitHub Desktop.
ListToJSController
public object Get
(
DateTime start,
DateTime end
)
{
//get model data and format for the table output
var modelData = Model.GetData(start, end)
.Select(l => new{
date = l.date.ToString("M/d/yyyy H:M tt"),
op = l.op,
salespoint = l.salespoint,
guest = l.guest,
guest_no = l.guest_no
})
.ToList();
var jsTable = ListToDataTable.ConvertListToJsDataTable(modelData);
//swip swap in some friendlier headers to protect the innocent
var headers = new List<JsDataTableRow>() {
new JsDataTableRow(){
cells = new List<JsDataTableCell>()
{
new JsDataTableCell(){value = "Date"},
new JsDataTableCell(){value = "Operator"},
new JsDataTableCell(){value = "Salespoint"},
new JsDataTableCell(){value = "Guest"},
new JsDataTableCell(){value = "Guest #"},
}
}
};
jsTable.headers = headers;
return new
{
options = new
{
bPaginate = false,
bLengthChange = false,
bFilter = false,
bAutowidth = true,
sDom = "t",
},
table = jsTable
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment