Telerik Forums
UI for Blazor Forum
3 answers
3.0K+ views

     Hi all, 

New to Blazor and Web development in General, but using Blazor as a way to bridge the gap between my c# knowledge and the web.

Just wondering if anyone has any knowledge of being able to do a if inside a Grid Column  The end goal i'm trying to achieve is if a value is contained within the the property of the CurrentRecord then a button will appear binding to a function, if no record appears then the cell would remain empty.

this is the code i'm bodged together

    <TelerikGrid data="@Histories" height="600px" Pageable="true" PageSize="20" Sortable="true" Filterable="true">
        <TelerikGridColumns>
            <TelerikGridColumn Field="Casecode" />
            <TelerikGridColumn Field="Historytext" />
            <TelerikGridColumn Field="Createdate" Title="Create Date" />
            <TelerikGridColumn>
                <Template>
                    @{ 
                        CurrentRecord = context as CaseHistory;
                        if(CurrentRecord.Blobid > 0)
                        {
                            <TelerikButton>Open</TelerikButton>
                        }
                     }
                </Template>

            </TelerikGridColumn>
        </TelerikGridColumns>
    </TelerikGrid>

 

 

at the moment when i'm running the code the command brower is showing an error 

 

Error: System.ArgumentNullException: Value cannot be null.
Parameter name: name
   at System.Type.GetProperty(String name, BindingFlags bindingAttr)
   at Telerik.Blazor.Components.Grid.TelerikGridFilterHeaderBase`1.get_PropInfo()
   at Telerik.Blazor.Components.Grid.TelerikGridFilterHeaderBase`1.get_PropType()
   at Telerik.Blazor.Components.Grid.TelerikGridFilterHeaderBase`1.get_PropTypeName()
   at Telerik.Blazor.Components.Grid.TelerikGridFilterHeaderBase`1.ResetFilterText()
   at Telerik.Blazor.Components.Grid.TelerikGridFilterHeaderBase`1.OnInit()
   at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()

 

any help to point me in a direction would help.

Thanks

Richard

Richard
Top achievements
Rank 1
 answered on 06 Jun 2019
8 answers
878 views

Hi,

I appreciate it's still under development so maybe what I ask is unavailable, but I have a couple of questions about the grid:

 

1. If I have a lot of columns can I set the size of the columns and have the grid display a horizontal scrollbar.

2. I'm having trouble getting sorting working with templated columns:

It doesn't seem to work at all when I just set the Items and when using the ReadItems method, which is ultimately what I want to do the sort descriptor is passed in but the sort descriptor member field is empty (the sort direction does contain a value). Do I need to set something on the column template as a sort value or something?

Thanks,
Nick

Marin Bratanov
Telerik team
 answered on 06 Jun 2019
3 answers
555 views

Hello,

I have edited the code below to remove a lot of the non-relevant parts. In summary I have a TelerikDropDownList within a TelerikGrid EditorTemplate within a TelerikWindow. When I click "Add" in the grid a NullReferenceException exception is thrown (full Exception text at the bottom of the post). If I comment out the DropDownList control completely, the exception is not thrown when I click "Add".

<TelerikWindow>
    <TelerikWindowContent>
        <TelerikGrid Data=@ScheduledJobs EditMode="inline">
            <TelerikGridToolBar>
                <TelerikGridCommandButton Command="Add" Icon="add"></TelerikGridCommandButton>
            </TelerikGridToolBar>
            <TelerikGridColumns>
                <TelerikGridColumn Field=@nameof(ScheduledJob.JobActionName) Title="Action">
                    <EditorTemplate>
                        @{
                            JobToEdit = context as ScheduledJob;
                            <TelerikDropDownList DefaultItem="@DefaultJobAction" Data="@JobActions" bind-Value=@JobToEdit.JobAction ValueField="@nameof(JobAction.Id)" TextField="@nameof(JobAction.Name)"></TelerikDropDownList>
                           }

...

@functions {

  protected List<JobAction> JobActions = <code to populate JobActions list>

  protected DefaultJobAction = JobActions[0];  // I have debugged - this assigns a non-null object as expected

  protected JobToEdit JobToEdit;  // has a field called JobAction of type JobAction

}

The full exception text is:

System.NullReferenceException: Object reference not set to an instance of an object. at string Telerik.Blazor.Common.TelerikSelectBase<TValue>.get_CurrentValueAsString() at void Telerik.Blazor.Components.DropDownList.TelerikDropDownList<TItem, TValue>.BuildRenderTree(RenderTreeBuilder builder) at Microsoft.AspNetCore.Components.ComponentBase()+(RenderTreeBuilder builder) => { } at void Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment) at void Microsoft.AspNetCore.Components.Rendering.Renderer.RenderInExistingBatch(RenderQueueEntry renderQueueEntry) at void Microsoft.AspNetCore.Components.Rendering.Renderer.ProcessRenderQueue()

Marin Bratanov
Telerik team
 answered on 04 Jun 2019
7 answers
474 views

I directly copy your example code from: https://demos.telerik.com/blazor-ui/grid/editing-incell into a server-side Blazor page using .Net Core 3 preview 5. Telerik UI for Blazor 0.5.0.

I run the app and the grid works perfectly apart from the "Add Employee" button. When I click it, it does nothing. No new blank row is added. Please note that the other grid command buttons work fine including "Delete" and "Edit".

Andrew
Top achievements
Rank 1
 answered on 03 Jun 2019
1 answer
1.3K+ views

Hi,

I'm trying to use the latest version (V1.1.0) of DropDownList with a GUID key, the original conversation is in this thread: https://www.telerik.com/forums/dropdownlist---run-code-when-select-item-changes.

My understanding is this should now work, but I'm having problems binding the current value. My code looks like this:

      <TelerikDropDownList Data="@_viewItems" TValue="Guid"
                             TextField="Name"
                             ValueField="Id"
                             bind-Value="@CurrentViewId" PopupHeight="120" />

 

    private List<NameAndId> _viewItems;

    public class NameAndId
    {
        public string Name { get; }
        public Guid Id { get; }

        public NameAndId(string name, Guid id)
        {
            Name = name;
            Id = id;
        }

        public override string ToString()
        {
            return Name;
        }
    }

    private Guid CurrentViewId
    {
        get => _currentViewId;
        set => _currentViewId = value;
    }

This gives me the following compiler error:

Severity    Code    Description    Project    File    Line    Suppression State
Error        The attribute names could not be inferred from bind attribute 'bind-Value'. Bind attributes should be of the form'bind', 'bind-value' or 'bind-value-change'    TestApp    C:\Source\TestApp.Blazor\TestApp.Blazor\Pages\View.razor    17    
Error    RZ9991    The attribute names could not be inferred from bind attribute 'bind-Value'. Bind attributes should be of the form'bind', 'bind-value' or 'bind-value-change'    TestApp  C:\Source\TestApp.Blazor\TestApp.Blazor\Pages\View.razor    17    

Thanks,

Nick.

 

 

Nick
Top achievements
Rank 1
 answered on 31 May 2019
1 answer
123 views
Hey guys I've been playing around with the components but am trying to do something like this and wonder if you have any ideas how to do it.

I currently have a number of tab strips which I can navigate between. However I want to make it more like a step by step interface. I was hoping to start off with one tab enabled and the rest disabled. Only once the user clicks the button would the next strip become enabled.

Is this something that is possible?



Marin Bratanov
Telerik team
 answered on 31 May 2019
3 answers
179 views

Hi - all of the dropdownlist code examples show data binding to lists of non-scalar types. I.e. lists of objects.

My question is, can your dropdownlist bind to lists of scalar types? I.e:

<TelerikDropDownList Data="@MyList" bind-Value=@MyItem />

@functions {

protected List<string> MyList() = new List<string>();

protected string MyItem;

}

If so, do I need to provide the ValueField and TextField properties?

Marin Bratanov
Telerik team
 answered on 31 May 2019
3 answers
338 views

I have a TelerikWindow containing a TelerikGrid, with EditMode="inline" and an "Add" TelerikGridCommandButton:

<TelerikWindow>
    <TelerikWindowContent>
        <TelerikGrid Data=@ScheduledJobs EditMode="inline">
            <TelerikGridToolBar>
                <TelerikGridCommandButton Command="Add" Icon="add"></TelerikGridCommandButton>
            </TelerikGridToolBar>
            <TelerikGridColumns>
                <TelerikGridColumn Field=@nameof(ScheduledJob.DateTime) Title="Date" />
            </TelerikGridColumns>
        </TelerikGrid>
    </TelerikWindowContent>
</TelerikWindow>

At run-time when I click the "Add" button in the grid I get the following error:

Microsoft.JSInterop.JSException: Could not find 'TelerikBlazorDateInput' in 'window'.

Error: Could not find 'TelerikBlazorDateInput' in 'window'.
    at https://localhost:5000/_framework/blazor.server.js:8:20878
    at Array.forEach (<anonymous>)
    at d (https://localhost:5000/_framework/blazor.server.js:8:20839)
    at https://localhost:5000/_framework/blazor.server.js:8:21429
    at new Promise (<anonymous>)
    at e.beginInvokeJSFromDotNet (https://localhost:5000/_framework/blazor.server.js:8:21403)
    at https://localhost:5000/_framework/blazor.server.js:1:16653
    at Array.forEach (<anonymous>)
    at e.invokeClientMethod (https://localhost:5000/_framework/blazor.server.js:1:16624)
    at e.processIncomingData (https://localhost:5000/_framework/blazor.server.js:1:14624)
   at async void Telerik.Blazor.Components.DateInput.TelerikDateInputBase.OnAfterRender()
   at void System.Threading.Tasks.Task.ThrowAsync(Exception exception, SynchronizationContext targetContext)+(object state) => { }
   at void Microsoft.AspNetCore.Components.Rendering.RendererSynchronizationContext.ExecuteSynchronously(TaskCompletionSource<object> completion, SendOrPostCallback d, object state)
   at void Microsoft.AspNetCore.Components.Rendering.RendererSynchronizationContext.ExecutionContextThunk(object state)
   at void Microsoft.AspNetCore.Components.Rendering.RendererSynchronizationContext.ExecuteBackground(WorkItem item)

 

If I change the data type of the column from DateTime to string, this error goes away.

Please assist?

Marin Bratanov
Telerik team
 answered on 29 May 2019
1 answer
133 views

 

Regarding https://docs.telerik.com/blazor-ui/common-features/dimensions in server-side Blazor.

"dimensions and positions are simple string properties that are not parsed by our code. You can provide valid CSS values to them. For example, 100px or 50%are valid options"

However when I use: Height="100px" or Height="100%" in many controls, including TelerikWindow and TelerikGrid, I get compile errors:

The name 'px' does not exist in the current context

and

Invalid expression term ')'

If I just use Height="100" then the Blazor app runs although I am still not sure the Height property is working properly.

Can you please confirm how this is supposed to work?

Marin Bratanov
Telerik team
 answered on 28 May 2019
1 answer
555 views

Do you have any examples yet on updating all clients from any of your controls?

Grid changes for example to update every connected client?

 

Marin Bratanov
Telerik team
 answered on 28 May 2019
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?