init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
86
KretaWeb/Helpers/Grid/Converter.cs
Normal file
86
KretaWeb/Helpers/Grid/Converter.cs
Normal file
|
@ -0,0 +1,86 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Text;
|
||||
using Kendo.Mvc;
|
||||
using Kendo.Mvc.Extensions;
|
||||
using Kendo.Mvc.UI;
|
||||
using Kreta.Core;
|
||||
using Kreta.Framework.Util;
|
||||
|
||||
namespace Kreta.Web.Helpers.Grid
|
||||
{
|
||||
public static class Converter
|
||||
{
|
||||
public static GridParameters GridParameter(DataSourceRequest request)
|
||||
{
|
||||
var gridParameters = new GridParameters
|
||||
{
|
||||
LoadResultSetInfo = true
|
||||
};
|
||||
|
||||
IList<SortDescriptor> sort = request.Sorts;
|
||||
if (sort != null && sort.Count > 0)
|
||||
{
|
||||
var sortString = new StringBuilder(string.Empty);
|
||||
foreach (SortDescriptor item in sort)
|
||||
{
|
||||
gridParameters.OrderDictionary.Add(item.Member, item.SortDirection);
|
||||
|
||||
sortString.Append(item.Member);
|
||||
sortString.Append(item.SortDirection == ListSortDirection.Ascending ? " ASC" : " DESC");
|
||||
sortString.Append(",");
|
||||
}
|
||||
|
||||
gridParameters.OrderBy = sortString.ToString(0, sortString.Length - 1);
|
||||
}
|
||||
|
||||
gridParameters.FirstRow = (request.Page - 1) * request.PageSize;
|
||||
gridParameters.LastRow = request.Page * request.PageSize - 1;
|
||||
|
||||
return gridParameters;
|
||||
}
|
||||
|
||||
[Obsolete(@"A ToDataSourceResult<T>-t kell használni model listákkal, mivel ezeket mostmár tudjuk sorbarendezni a GridParameters-el,
|
||||
így nincs szükség rá, hogy elmenjen a DataSet a Web-re ezért nincs is szükség itt sorrenezni őket!")]
|
||||
public static DataSourceResult ToDataSourceResult(this DataSet dataSet, DataSourceRequest request = null)
|
||||
{
|
||||
if (dataSet.Tables.Count < 1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
DataTable firstLevel = dataSet.Tables[0];
|
||||
DataSourceResult result = firstLevel.ToDataSourceResult(request ?? new DataSourceRequest());
|
||||
result.Total = Convert.ToInt32(firstLevel.ExtendedProperties["RowCount"]);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generikus objektumlistából készítünk Kendo-s DataSourceResult-ot a Kendo-s grid-eknek.
|
||||
/// Sorba rendezzük az adatokat és beállítjuk a lapozást a GridParameters objektum alapján a SortingAndPaging extension method-dal.
|
||||
/// Végül visszaadjuk az eredményt, beállítva az összes elem számát is(ez az összes elem számának megjelenítéséhez kell a grid-en).
|
||||
/// </summary>
|
||||
/// <typeparam name="T">A T bármilyen típusú objektum lehet, de leginkább Model-ekkel kellene használni.</typeparam>
|
||||
/// <param name="itemList">A T típusú objektumlista, amivel dolgozunk.</param>
|
||||
/// <param name="gridParameters">A GridParameters property-jei(OrderList, FirstRow, LastRow) alapján határozzuk meg, hogy milyen paraméterek alapján rendezzünk sorba és állítjuk be a lapozást.</param>
|
||||
/// <returns></returns>
|
||||
public static DataSourceResult ToDataSourceResult<T>(this List<T> itemList, GridParameters gridParameters = null)
|
||||
{
|
||||
if (itemList == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
List<T> data = gridParameters == null ? itemList : itemList.SortingAndPaging(gridParameters.OrderDictionary, gridParameters.FirstRow, gridParameters.LastRow);
|
||||
var dataSourceResult = new DataSourceResult
|
||||
{
|
||||
Data = data,
|
||||
Total = itemList.Count
|
||||
};
|
||||
|
||||
return dataSourceResult;
|
||||
}
|
||||
}
|
||||
}
|
8
KretaWeb/Helpers/Grid/ExportColumn.cs
Normal file
8
KretaWeb/Helpers/Grid/ExportColumn.cs
Normal file
|
@ -0,0 +1,8 @@
|
|||
namespace Kreta.Web.Helpers.Grid
|
||||
{
|
||||
public class ExportColumn
|
||||
{
|
||||
public string Field { get; set; }
|
||||
public string Title { get; set; }
|
||||
}
|
||||
}
|
18
KretaWeb/Helpers/Grid/FunctionCommand.cs
Normal file
18
KretaWeb/Helpers/Grid/FunctionCommand.cs
Normal file
|
@ -0,0 +1,18 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace Kreta.Web.Helpers.Grid
|
||||
{
|
||||
public class FunctionCommand
|
||||
{
|
||||
public FunctionCommand()
|
||||
{
|
||||
Enabled = true;
|
||||
}
|
||||
public string Name { get; set; }
|
||||
public int? NameResourceId { get; set; }
|
||||
public string ClientAction { get; set; }
|
||||
public bool Enabled { get; set; }
|
||||
public string Classes { get; set; }
|
||||
public List<FunctionCommand> NestedCommands { get; set; }
|
||||
}
|
||||
}
|
28
KretaWeb/Helpers/Grid/GridApiUrl.cs
Normal file
28
KretaWeb/Helpers/Grid/GridApiUrl.cs
Normal file
|
@ -0,0 +1,28 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Web.Routing;
|
||||
|
||||
namespace Kreta.Web.Helpers.Grid
|
||||
{
|
||||
public class GridApiUrl
|
||||
{
|
||||
public string Route { get; private set; }
|
||||
|
||||
public RouteValueDictionary RouteValues { get; private set; }
|
||||
|
||||
public GridApiUrl(string controller, string action, string route = Constants.RouteKey.ActionApi)
|
||||
{
|
||||
RouteValues = new RouteValueDictionary();
|
||||
RouteValues.Add("controller", controller);
|
||||
RouteValues.Add("action", action);
|
||||
Route = route;
|
||||
}
|
||||
|
||||
public GridApiUrl(string controller, string action, IDictionary<string, string> parameters, string route = Constants.RouteKey.ActionApi) : this(controller, action, route)
|
||||
{
|
||||
foreach (var item in parameters)
|
||||
{
|
||||
RouteValues.Add(item.Key, item.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
12
KretaWeb/Helpers/Grid/GridButtonColumn.cs
Normal file
12
KretaWeb/Helpers/Grid/GridButtonColumn.cs
Normal file
|
@ -0,0 +1,12 @@
|
|||
using Kreta.Enums.ManualEnums;
|
||||
|
||||
namespace Kreta.Web.Helpers.Grid
|
||||
{
|
||||
public class GridButtonColumn
|
||||
{
|
||||
public string LinkTitle { get; set; }
|
||||
public string FunctionClientName { get; set; }
|
||||
public GridButtonsEnum ButtonType { get; set; }
|
||||
public string HiddenCondition { get; set; }
|
||||
}
|
||||
}
|
10
KretaWeb/Helpers/Grid/KretaGridDataSourceRequest.cs
Normal file
10
KretaWeb/Helpers/Grid/KretaGridDataSourceRequest.cs
Normal file
|
@ -0,0 +1,10 @@
|
|||
using Kendo.Mvc.UI;
|
||||
|
||||
namespace Kreta.Web.Helpers.Grid
|
||||
{
|
||||
public class KretaGridDataSourceRequest : DataSourceRequest
|
||||
{
|
||||
/*js ből jön ne nevezd át*/
|
||||
public string data { get; set; }
|
||||
}
|
||||
}
|
16
KretaWeb/Helpers/Grid/RowFunction.cs
Normal file
16
KretaWeb/Helpers/Grid/RowFunction.cs
Normal file
|
@ -0,0 +1,16 @@
|
|||
using Kreta.Enums.ManualEnums;
|
||||
|
||||
namespace Kreta.Web.Helpers.Grid
|
||||
{
|
||||
public class RowFunction
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public int? NameResourceId { get; set; }
|
||||
public string ClientAction { get; set; }
|
||||
public GridRowFunctionIconEnum? IconEnum { get; set; }
|
||||
public bool IsConditional { get; set; }
|
||||
public bool IsMultipleConditionalColumn { get; set; }
|
||||
public string IsVisibleRowFunctionJsFunctionName { get; set; }
|
||||
public bool SendSender { get; set; }
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue