Good afternoon,
I am relatively new developer. I am working the the Telerik Grid and it is fantastic! The sorting and searching and editing I love it!
I have made my own custom command button that when clicked pops a modal dialog that displays a pdf. The link to display this pdf is stored in the database. All of this works great!
Now I would like to only display a button or enable this button if this field has something in it.
I am not picky about how its done either. I have tried to bind the enable event to a Has_Link boolean field...I have tried a bunch of stuff.
I realize this probably has more to do with my lack of knowledge than it does the control itself. If someone could point me in the right direction, I would be grateful!
Here is my code below.
<AuthorizeView> <Authorized> <h3>Search Permit</h3> @if (Permits == null) { <p><em>Loading...</em></p> } else { <TelerikGrid Data=@Permits EditMode="@GridEditMode.Incell" @ref="Grid" Sortable="true" FilterMode="GridFilterMode.FilterMenu" Class="table-striped" Height="750px" Pageable="true" PageSize=@PageSize OnUpdate=@UpdateItem OnDelete=@DeleteItem> <GridToolBar> <br /> </GridToolBar> <GridColumns> <GridColumn Field=@nameof(Permit.Permit_NO) Title="Permit Number" /> <GridColumn Field=@nameof(Permit.Parcel) /> <GridColumn Field=@nameof(Permit.PD_Owner) Title="Owner Name" /> <GridColumn Field=@nameof(Permit.Submission_Date) Title="Submit Date" /> <GridColumn Field=@nameof(Permit.Permit_Issue_Date) Title="Issue Date" /> <GridColumn Field=@nameof(Permit.Permit_Type) Title="Permit Type" /> <GridColumn Field=@nameof(Permit.Estimated_Cost) Title="Cost" /> <GridColumn Field=@nameof(Permit.Fee) Title="Cost" /> <GridColumn Field=@nameof(Permit.Note) /> <GridColumn Field=@nameof(Permit.Image_Link) /> <GridColumn Field=@nameof(Permit.Has_Link) /> <GridCommandColumn> <GridCommandButton Command="Delete" Icon="delete">Delete</GridCommandButton> <GridCommandButton Command="Save" Icon="save" ShowInEdit="true">Save</GridCommandButton> <GridCommandButton Enabled="ShowImageIsEnabled" OnClick="Show_Image" Icon="information">Show Permit</GridCommandButton> </GridCommandColumn> </GridColumns> </TelerikGrid> } </Authorized> <NotAuthorized> <h1>Access Denied!</h1> </NotAuthorized></AuthorizeView>@code { private List<PermitModel> Permits = new List<PermitModel>(); private PermitModel Permit = new PermitModel(); public TelerikGrid<PermitModel> Grid { get; set; } public bool ShowImageIsEnabled { get; set; } = true; int PageSize = 15; protected override async Task OnInitializedAsync() { Permits = await _db.GetPermitData(); await SetGridSort(); } private void DeleteItem(GridCommandEventArgs args) { var argsItem = args.Item as PermitModel; Permits.Remove(argsItem); _db.DeletePermit(argsItem); } private void UpdateItem(GridCommandEventArgs args) { var argsItem = args.Item as PermitModel; var index = Permits.FindIndex(i => i.Record_ID == argsItem.Record_ID); if (index != -1) { Permits[index] = argsItem; } _db.DeletePermit(argsItem); _db.InsertPermit(argsItem); } async Task SetGridSort() { GridState<PermitModel> desiredState = new GridState<PermitModel>() { SortDescriptors = new List<SortDescriptor>() { new SortDescriptor { Member = "Permit_NO", SortDirection = ListSortDirection.Descending } } }; await Grid.SetState(desiredState); } void Show_Image(GridCommandEventArgs args) { var argsItem = args.Item as PermitModel; var parameters = new ModalParameters(); parameters.Add(nameof(ImageModal.image), argsItem.Image_Link); Modal.Show<ImageModal>(argsItem.Permit_NO, parameters); }}