This is a migrated thread and some comments may be shown as answers.

Inline editor login?

2 Answers 23 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rob
Top achievements
Rank 1
Rob asked on 24 Sep 2018, 06:52 PM

I apologize if this is a silly question but is it possible that a single grid that has the inline editing capabilities for logged in users and just a read only grid for everyone else? If so where do I start?

Looking at the demo I thought I would have to create 2 grids and password-protect the one with inline-editing.

 

Thanks in advance

2 Answers, 1 is accepted

Sort by
0
Accepted
Georgi
Telerik team
answered on 26 Sep 2018, 09:56 AM
Hello Rob,

A possible solution is to check whether the current request is authenticated and in case it is include the editable configuration to the grid. If it is not omit it.

e.g.

@{
    var isLogged = Request.IsAuthenticated;
    var grid = Html.Kendo().Grid<Model>();
 
    if (isLogged)
    {
        grid.Editable();
    }
}
 
@(  grid.Name("grid")
        .Columns(columns =>
        {
            
            ...  
            
            if (isLogged)
            {
                columns.Command(x => x.Edit());
            }
        })
        ...
        .DataSource(dataSource => {
 
            var ds =  dataSource.Ajax();
 
            ds.Read(read => read.Action("GetData", "Home"));
 
            if (isLogged)
            {
                ds.Update(x => x.Action("EditData", "Home"));
                ds.Create(x => x.Action("CreateData", "Home"));
            }
 
            ds.PageSize(20);
            ds.Model(x => x.Id(y => y.Id));
        }
 
        )
)


Regards,
Georgi
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Rob
Top achievements
Rank 1
answered on 10 Oct 2018, 01:57 PM
Thank you! This worked great!
Tags
Grid
Asked by
Rob
Top achievements
Rank 1
Answers by
Georgi
Telerik team
Rob
Top achievements
Rank 1
Share this question
or