Bind Datatable :Call a javascript function and pass value to function from partial view
Bind Datatable :Call a javascript function and pass value to function from partial view
Tejaswinij
Posts: 2Questions: 2Answers: 0
I have defined a function 'formatPrice' in accountJS file, which I want to call while binding jquery datatable in a partial view.Along with that I want to pass the value to this function @item.price. Below is the code, where I am not getting how the "accountJS.formatPrice" function to be called
@model List<Products>
<table id="datatableResult" class="searchgrid">
<thead>
<tr>
<th>Id</th>
</tr>
<tr>
<th>Product Price</th>
</tr>
</thead>
<tbody>
@if (Model != null)
{
foreach (var item in Model)
{
<tr>
<td>@item.Id</td>
<td>>! accountJS.formatPrice(@item.price)</td>
</tr>
}
}
</tbody>
</table>
This discussion has been closed.
Answers
I might be wrong, but this appears to be more of a .NET question than one specific to DataTables. Does your code above create an HTML table when rendered in the browser? If so, what does that HTML look like please ("View source" in the browser)?
If it is a .NET issue just creating the HTML, you'd need to ask at SO or similar.
Allan