@model List<Faq>
@using EImece.Domain.Helpers;
@using GridMvc.Html
@using GridMvc.Sorting
@using EImece.Domain;
@using EImece.Domain.Entities;
@using Resources;
@using EImece.Domain.Helpers.Extensions;
@using Resources;

@{
    ViewBag.Title = AdminResource.Faq;
    Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml";

    int pageSizeNumber = Request.QueryString["GridPageSize"].ToInt();
    pageSizeNumber = pageSizeNumber == 0 ? AppConfig.GridPageSizeNumber : pageSizeNumber;
    var controllerName = "Faq";
    var gridName = "FaqGrid";
    var contents = Model;
    var baseList = contents.DownCasting<Faq>();

    var gridImagesText = AdminResource.GridImagesText;
    var gridEditText = AdminResource.GridEditText;
    var gridDeleteText = AdminResource.GridDeleteText;
    var gridDetailText = AdminResource.GridDetailText;
    var gridMainPageImageText = AdminResource.GridMainPageImageText;

}

<h2>@AdminResource.Faq</h2>
<hr class="adminLine" />

@Html.Partial("pGridOperations", new ViewDataDictionary(ViewData){
        {"controllerName",controllerName}
                 ,{"StateTypes","State"}
       ,{"orderingButton",true}
       ,{"selectAll",true}
       ,{"deleteAll",true}
        ,{"SetStateOnOrOff",true},{"IsExcelButtonEnabled",true}})

<div class="panel panel-primary">
    @Html.Partial("pGridDropDown", baseList)
    @Html.Grid(contents).Named(gridName).Columns(columns =>
{

columns.Add(o => o.Id, true);

columns.Add()
               .Encoded(false)
               .Sanitized(false)
                .Css("gridButtons")
               .RenderValueAs(d => Html.Partial("pGridCheckbox", new ViewDataDictionary(ViewData){
            {"ItemId",d.Id}}));

columns.Add()
                       .Encoded(false)
                       .Sanitized(false)
                       .SetWidth(30)
                       .RenderValueAs(d =>
    @<b>
        @Html.ActionLink(" ", "SaveOrEdit", controllerName, new { id = d.Id }, new { @class = "btn btn-primary  btn-xs   glyphicon glyphicon-pencil glyphicon-white     " })
    </b>);

    if (UserRoleHelper.IsDeletedEnableRoles())
    {
        columns.Add()
        .Encoded(false)
        .Sanitized(false)
        .SetWidth(30)
        .RenderValueAs(d => Html.Partial("pDeleteModal", new ViewDataDictionary(ViewData) {
{ "ItemId", d.Id },
{"controllerName",controllerName},
{ "DeleteText", gridDeleteText },
{ "DeleteIcon", "gridBtn btn btn-danger btn-xs glyphicon  glyphicon-remove-circle" },
{ "ItemDescription", d.Name } }));

    }

    columns.Add(c => c.Question)
    .Titled(AdminResource.Question)
    .Filterable(true);

    columns.Add(o => o.Answer)
.Titled(AdminResource.Answer)
.Encoded(false).
    Sanitized(false).
    SetWidth(10).
    RenderValueAs(o => String.Format("<textarea readonly  style='height: 100px; background-color: transparent; width: 589px; margin: 0px;'>{0}</textarea>", GeneralHelper.StripHtml(o.Answer).ToStr(1000)));

    columns.Add(o => o.Position).Titled(AdminResource.Position)
.Encoded(false).
Sanitized(false).
SetWidth(10).
RenderValueAs(o => String.Format("<input   gridkey-id='{0}' value='{1}'   class='GridOrderingTextbox input-xs' name='gridOrdering' type='type'>", o.Id, o.Position));

    columns.Add(o => o.IsActive)
    .Titled("State")
    .Sortable(true)
    .SortInitialDirection(GridSortDirection.Descending).Encoded(false).
    Sanitized(false)
    .RenderValueAs(o => String.Format("<span  gridkey-id='{0}' grid-data-value='{2}' {1}   name='spanState'> </span>",
                 o.Id, (o.IsActive ? Constants.OkStyle : Constants.CancelStyle), o.IsActive));

    columns.Add(o => o.UpdatedDate)
    .Titled("UpdatedDate")
    .Sortable(true)
    .Css("gridDateClass")
    .RenderValueAs(o => String.Format("{0}", o.UpdatedDate.ToShortDateString()))
    .SortInitialDirection(GridSortDirection.Descending);

}).SetRowCssClasses(item => item.IsActive ? string.Empty : "GridIsActive").WithPaging(pageSizeNumber).Sortable().Filterable().WithMultipleFilters().Selectable(false)
</div>