Hey,
I am developing a grid that takes in a model, but inside the model the variable it needs is an IEnumerable.
We have controllers filling this IEnumerable and it works without the ClientRowTemplate and the DataSource that we have on it, but the second we add both of those elements in, it stops working, it is blank, and does not show any errors.
Here is the code:
Here is the call TWO CALLS to get the PartialView when the View is built:
The IEnumerable in the QuoteLineGridViewModel is this:
Here is the Controller method to fill the IEnumerable:
Our theory is that it is not getting the current item in the IEnumerable, but we are not completely sure on why it doesn't work.
We tried going through the API/Documentation to see if a RowTemplate would be better, but we did not find much on this topic for the KendoUI.
The reason we are doing it this way is because we want to eventually be able to change the way a row displays using conditional statements.
Please let me know if you need more information or clarification for what is going on and what the end result is.
I am developing a grid that takes in a model, but inside the model the variable it needs is an IEnumerable.
We have controllers filling this IEnumerable and it works without the ClientRowTemplate and the DataSource that we have on it, but the second we add both of those elements in, it stops working, it is blank, and does not show any errors.
Here is the code:
@model NS.Quoting.Models.ViewModels.QuoteLineGridViewModel
@(Html.Kendo().Grid(Model.QuoteLines)
.Name("QuotesGrid")
.Columns(columns => {
columns.Bound(c => c.LineNumber).Filterable(false).Width(60).Title("Line #");
columns.Bound(c => c.ItemNumber).Title("Material #");
columns.Bound(c => c.ItemDescription).Title("Material Name");
columns.Bound(c => c.Quantity).Filterable(false).Width(70).Title("Quantity");
columns.Bound(c => c.SalePrice).Filterable(false).Width(81).Title("Quoted Price");
columns.Bound(c => c.LinePrice).Filterable(false).Width(60).Title("Extended Price");
columns.Bound(c => c.MarginPercent).Filterable(false).Width(60).Title("Margin %");
})
.ClientRowTemplate(
"<
tr
>" +
"<
td
class
=
'line'
>" +
"<
span
class
=
'linenumber'
> #: LineNumber # </
span
>" +
"</
td
>" +
"<
td
class
=
'materialNum'
>" +
"<
span
class
=
'itemnumber'
> #: ItemNumber # </
span
>" +
"</
td
>" +
"<
td
class
=
'materialName'
>" +
"<
span
class
=
'itemdescription'
> #: ItemDescription # </
span
>" +
"</
td
>" +
"<
td
class
=
'QTY'
>" +
"<
span
class
=
'quantity'
> #: Quantity # </
span
>" +
"</
td
>" +
"<
td
class
=
'quotedPrice'
>" +
"<
span
class
=
'saleprice'
> #: SalePrice # </
span
>" +
"</
td
>" +
"<
td
class
=
'extendedPrice'
>" +
"<
span
class
=
'lineprice'
> #: LinePrice # </
span
>" +
"</
td
>" +
"<
td
class
=
'marginPerc'
>" +
"<
span
class
=
'marginpercent'
> #: MarginPercent # </
span
>" +
"</
td
>" +
"</
tr
>"
)
.DataSource(dataSource => dataSource
.Ajax().ServerOperation(false)
)
.Pageable(pager => pager.PageSizes(new int[]{10,25,50}))
.Scrollable()
.Sortable()
.Filterable()
)
Here is the call TWO CALLS to get the PartialView when the View is built:
<
div
id
=
"itemGrids"
>
<
h3
>Active Items</
h3
>
<
div
id
=
"newAct"
>
@Html.Action("GetGrid", "Quote", new { id = Model.Quote.QuoteNumber, isActive = true })
</
div
>
<
h3
>Inctive Items</
h3
>
<
div
id
=
"newDe"
>
@Html.Action("GetGrid", "Quote", new { id = Model.Quote.QuoteNumber, isActive = false })
</
div
>
</
div
>
The IEnumerable in the QuoteLineGridViewModel is this:
public IEnumerable<
QuoteLineSummary
> QuoteLines { get; set; }
Here is the Controller method to fill the IEnumerable:
public
PartialViewResult GetGrid(
int
id,
bool
isActive)
{
QuoteLineGridViewModel model =
new
QuoteLineGridViewModel();
using
(var client =
new
HttpClient())
{
// URL: /api/QuoteLine/GetByQuoteNumber/1
var lineUrl = Url.RouteUrl(
"ActionApi"
,
new
{ httproute =
""
, controller =
"QuoteLine"
, action =
"GetSummaryByQuoteNumber"
, id = id, isActive = isActive },
Request.Url.Scheme
);
model.QuoteLines = client
.GetAsync(lineUrl)
.Result
.Content.ReadAsAsync<IEnumerable<QuoteLineSummary>>().Result;
}
return
PartialView(
"_QuoteLineGrid"
, model);
}
Our theory is that it is not getting the current item in the IEnumerable, but we are not completely sure on why it doesn't work.
We tried going through the API/Documentation to see if a RowTemplate would be better, but we did not find much on this topic for the KendoUI.
The reason we are doing it this way is because we want to eventually be able to change the way a row displays using conditional statements.
Please let me know if you need more information or clarification for what is going on and what the end result is.