41 lines
1.4 KiB
C#
41 lines
1.4 KiB
C#
using System.Web;
|
|
using System.Web.Mvc;
|
|
using Kendo.Mvc.UI;
|
|
using Kendo.Mvc.UI.Fluent;
|
|
using Kreta.Web.Helpers.Grid;
|
|
|
|
namespace Kreta.Web.Helpers
|
|
{
|
|
public static class ListViewExtensions
|
|
{
|
|
public static ListViewBuilder<ListViewModel> KretaListView<ListViewModel>(this HtmlHelper helper,
|
|
string name,
|
|
string tagName,
|
|
string clientTemplateId,
|
|
ApiUrlBuilder getUrl,
|
|
bool pageable = false,
|
|
bool autoBind = true,
|
|
bool serverOperation = false)
|
|
where ListViewModel : class
|
|
{
|
|
var urlHelper = new UrlHelper(HttpContext.Current.Request.RequestContext);
|
|
string url = urlHelper.HttpRouteUrl(getUrl.Route, getUrl.RouteValues);
|
|
|
|
ListViewBuilder<ListViewModel> listViewBuilder = helper.Kendo().ListView<ListViewModel>()
|
|
.Name(name)
|
|
.TagName(tagName)
|
|
.ClientTemplateId(clientTemplateId)
|
|
.DataSource(dataSource =>
|
|
{
|
|
dataSource.Read(read => read.Url(url).Type(HttpVerbs.Get));
|
|
dataSource.ServerOperation(serverOperation);
|
|
})
|
|
.Pageable(x => x.Enabled(pageable))
|
|
.AutoBind(autoBind);
|
|
|
|
listViewBuilder.Render();
|
|
|
|
return listViewBuilder;
|
|
}
|
|
}
|
|
}
|