Dear Group,
I am currently implementing a client-side paging solution using ASP.NET, jQuery and JSON.
I have been following the excellent article from encosia: http://encosia.com/2008/08/20/easily-build-powerful-client-side-ajax-paging-using-jquery/
In my Web Method I retrieve my data from the database as a DataTable:
DataTable categoryProducts = ProductViewerAccess.GetCategoryProducts
("AA", 4, 0, Page.ToString(), out howManyPages, "FALSE", 0, "CostPrice", "asc", destinationList);
I then retrieve the data from the DataTable into an anonymous type:
var feeds =
from feed in categoryProducts.AsEnumerable()
select new
{
Description = feed.Field<string>("description"),
MfPartNo = feed.Field<string>("MfPN"),
Inventory = feed.Field<Int32>("Inventory")
};
The anonymous type is then returned from the Web Method to the client-side:
return feeds.Take(PageSize);
A template then extracts and displays the fields:
<tbody>
{#foreach $T.d as post}
<tr>
<td>
{$T.post.Description}
<p>Mfr#: {$T.post.MfPartNo}</p>
</td>
<td>{$T.post.Inventory}</td>
</tr>
{#/for}
</tbody>
This all works great.
However, I would like to extend the code to perform some evaluation checks (e.g., check that various columns in the DataTable are not NULL) and other pre-processing (e.g., call various functions to build the image URL based on the image ID - which is another column in the DataTable not shown in the code fragment) before I return the resulting rows of the DataTable as an anonymous type to the client-side.
Basically, I want to iterate through the DataTable, perform the evaluation checks and pre-processing, while building my anonymous type manually as I go. Or maybe there is a better way to achieve this?
Is there anyway I can achieve this?
Kind Regards
Walter