saifuddinazhar
10/7/2019 - 6:39 AM

User Column Preference

add, implement, view, setting

.csthml inside wrapActionButton:
@Html.Partial("_MenuUserColumnPreference")
Ex:
@Html.Partial("_MenuUserColumnPreference")
<div class="btn-group">
    <button class="icon-savefilter" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true" onclick="showFilterMenu()"></button>
    <div class="dropdown-menu" id="gridFilterLocation"></div>
</div>

var userID = '@ViewBag.UserID';
var mainGridID = '@ViewBag.MainGridID'; 
var isCanEditAllUserColumnPreference = @Convert.ToBoolean(ViewBag.IsCanEditAllUserColumnPreference).ToString().ToLower();
var selfUserColumnPreference = '@ViewBag.SelfUserColumnPreference' == '' ? [] : JSON.parse('@Html.Raw(ViewBag.SelfUserColumnPreference)');
var allUserColumnPreference = '@ViewBag.AllUserColumnPreference' == '' ? [] : JSON.parse('@Html.Raw(ViewBag.AllUserColumnPreference)');
        
-----------------

.cs controller:
ApplyUserColumnPreference(user, "transactGrid");

-----------------

.js
* Add each kendo column hidden, ex: 
{ field: "CreatedAt", title: gridTitleCreatedOn, template: "#= formatDateTime(CreatedAt) #", hidden: isColumnPreferenceHidden("CreatedAt") },
* Add renderMenuColumnPreferenceList() after init kendo
Ex:
$('#gridName').kendoGrid({ /**/ })
renderMenuColumnPreferenceList();