Telerik Forums
UI for ASP.NET Core Forum
4 answers
143 views

I have a Core grid that manages the Sol objects. 

<div class="col-sm-12">
    @(Html.Kendo().Grid(Model)
                    .Name("mySolsGrid")
                    .Columns(columns =>
                    {
                        columns.Bound(c => c.Nom).Width(140);
                        columns.Bound(c => c.Code).Width(190);
                        columns.Command(command => { command.Edit(); command.Destroy(); }).Width(172);
                    })
                    .ToolBar(
                        toolbar => {
                            toolbar.Create();
                            toolbar.Excel();
                        }
                    )
                    .Editable(editable => editable.Mode(GridEditMode.InLine))
                    .Pageable()
                    .Sortable()
                    .Scrollable(scr=>scr.Height(430))
                    .Filterable()
                    .DataSource(dataSource => dataSource
                        .Ajax()
                        .PageSize(20)
                        .Events(events => events.Error("error_handler"))
                        .Model(model => model.Id(p => p.Id))
                        .Create(update => update.Action("Sols_Create", "Sols"))
                        .Read(read => read.Action("Sols_Read", "Sols"))
                        .Update(update => update.Action("Sols_Update", "Sols"))
                        .Destroy(update => update.Action("Sols_Destroy", "Sols"))
                    )
                    )
</div>

This is my controller: 

[AcceptVerbs("Post")]
public async Task<ActionResult> Sols_CreateAsync([DataSourceRequest] DataSourceRequest request, SolDTO solDto)
{
    SolDTO idOnly = solDto;
    if (solDto != null && ModelState.IsValid)
    {
        idOnly = await _solService.CreateAsync(solDto);               
    }
 
    return Json(new[] { idOnly }.ToDataSourceResult(request, ModelState));
}

this is my Service returning object:

public async Task<SolDTO> CreateAsync(SolDTO solDto)
{
    var sol = _mapper.Map<Sol>(solDto);
    await _userService.SetCreatedByCurrentUserNowAsync(sol);
 
    sol = await _repository.AddAsync(sol);
    var dto = _mapper.Map<SolDTO>(sol);
    return dto;
}

I return here the ID that is not 0. However each time I add a new object (i click on update button) it calls the Create function one more time. First call once, second twice etc.

Does the Async method have something to do with that? 

Georgi Denchev
Telerik team
 answered on 27 Apr 2021
1 answer
202 views

what is that

source = Regex.Replace(source, @"\$\(document\)\.on\(""kendoReady"",", "$(document).ready(", RegexOptions.Multiline);

 

in the ASP.NET Core Examples code?

Should I understand that all the document.on('kendoReady' in fact should not be used, and instead "document.Ready" should be used ?

How a developer that usually copies only parts of examples should guess that hack?

 

Neli
Telerik team
 answered on 27 Apr 2021
1 answer
208 views

I try to implement a simple databinding in the Spreadseet, in an ASP.NETCore MVC application.

I read this article, "Specific behavior"

There it says in the first point : "Column headers are inferred from the data item fields. Configure the column headers and ordering by using the sheet setDataSource method."

The link on setDataSource goes to DataSource method of the jQuery (?!) component ...I didn't find any setDataSource in exemple code from github, there is a DataSource method, however it does not work locally...

please bring some clearly on how to bind the datasource with a simpler example maybe?

I can put my example here, I just try to bind to a datasource to display a "name" and "id", but it does not work, it reads the data from the server, but does not display that json collection that I return in the sheet. 

001.        <div class="row">
002.            <div class="col-sm-12">
003.                <div id="example">
004.                    <script src="https://kendo.cdn.telerik.com/2021.1.330/js/jszip.min.js"></script>
005. 
006.                    <div class="configurator">
007.                        <div class="header">Configurator</div>
008.                        <div class="box-col">
009.                            <h4>Save data changes</h4>
010.                            <ul class="options">
011.                                <li>
012.                                    <button id="save">Save changes</button>
013.                                    <button id="cancel">Cancel changes</button>
014.                                </li>
015.                            </ul>
016.                        </div>
017.                    </div>
018. 
019.                    @(Html.Kendo().Spreadsheet()
020.    .Name("spreadsheet")
021.    .HtmlAttributes(new { style = "width:100%" })
022.    .Toolbar(false)
023.    .Sheetsbar(false)
024.    .Events(e => e
025.        .DataBinding("onDataBinding")
026.        .DataBound("onDataBound")
027.    )
028.    .Excel(excel => excel
029.        .ProxyURL(Url.Action("Index_Save", "Entreprises"))
030.    )
031.    .Pdf(pdf => pdf
032.        .ProxyURL(Url.Action("Index_Save", "Entreprises"))
033.    )
034.    .Sheets(sheets =>
035.    {
036.        sheets.Add()
037.            .Name("Products")
038.            .DataSource<EntrepriseDTO>(ds => ds
039.                .Custom()
040.                .Batch(true)
041.                .Transport(t => t
042.                    .Read("onRead")
043.                    .Submit("onSubmit")
044.                )
045.                .Events(e => e.Change("onChange"))
046.                .Schema(s => s
047.                    .Model(m =>
048.                    {
049.                        m.Id(p => p.Id);
050.                    })
051.                )
052.            )
053.            .Columns(columns =>
054.            {
055.                columns.Add().Width(100);
056.                columns.Add().Width(415);
057.                columns.Add().Width(145);
058.                columns.Add().Width(145);
059.                columns.Add().Width(145);
060.                columns.Add().Width(145);
061.            })
062.            .Rows(rows =>
063.            {
064.                rows.Add().Height(40).Cells(cells =>
065.                {
066.                    cells.Add()
067.                        .Bold(true)
068.                        .Background("#9c27b0")
069.                        .TextAlign(SpreadsheetTextAlign.Center)
070.                        .Color("white");
071. 
072.                    cells.Add()
073.                        .Bold(true)
074.                        .Background("#9c27b0")
075.                        .TextAlign(SpreadsheetTextAlign.Center)
076.                        .Color("white");
077. 
078.                    cells.Add()
079.                        .Bold(true)
080.                        .Background("#9c27b0")
081.                        .TextAlign(SpreadsheetTextAlign.Center)
082.                        .Color("white");
083. 
084.                    cells.Add()
085.                        .Bold(true)
086.                        .Background("#9c27b0")
087.                        .TextAlign(SpreadsheetTextAlign.Center)
088.                        .Color("white");
089. 
090.                    cells.Add()
091.                        .Bold(true)
092.                        .Background("#9c27b0")
093.                        .TextAlign(SpreadsheetTextAlign.Center)
094.                        .Color("white");
095. 
096.                    cells.Add()
097.                        .Bold(true)
098.                        .Background("#9c27b0")
099.                        .TextAlign(SpreadsheetTextAlign.Center)
100.                        .Color("white");
101.                });
102.            });
103.    })
104.)
105.                </div>
106.            </div>
107.        </div>
Neli
Telerik team
 answered on 27 Apr 2021
2 answers
130 views

Hello, 

I am having a slight styling issue with a drop down list within a kendo grid pop up editor. This is the only drop down list that is behaving like this in our application and the code is exactly the same as in other places where we have used the grids. 

As you can see from the screen shot PersonId is a foreign key using a UI hint to display the drop down list, however, it seems like it has a mind of its own and is deciding to display the drop down options on the top right hand side of the page when clicked upon. Any suggestions on how to debug this will be helpful, thank you! 

Neli
Telerik team
 answered on 27 Apr 2021
3 answers
626 views

I have a requirement to print a chart. The chart should be displayed in a small area and I need to modify the font-size on all texts. I have found that you could use the text { font-size: 8px !important; } but this one is ignored when I do the actual printing (The printing is done using the teletik printion on pdf)

How can I decrease all the texts in a chart or change the default sizing?

Nikolay
Telerik team
 answered on 27 Apr 2021
3 answers
178 views
The only way that Telerik manages to work on my machine is when it is ran as Administrator. Is there any work around to this?
sung-gu
Top achievements
Rank 1
 answered on 27 Apr 2021
9 answers
372 views

Hello, 

 

I would like to ask if the telerok spreadsheet for asp.net core is able to be linked to a (sqlserver) datasource, and display to the user only the grid (columns and custom column names), without excel-like row and column names, something like is defined by red rectangle in the attached picture

serge
Top achievements
Rank 2
Bronze
Iron
Iron
 answered on 26 Apr 2021
1 answer
145 views

 want to have a filter row in my grid but only display the filter for some columns.  How can i do this?

 

ALSO .. how do I decide whether it is a textbox, calendar or numeric data entry?

 

Also .. can a date range be specified?

Eyup
Telerik team
 answered on 23 Apr 2021
1 answer
554 views

I'm using the RadioGroup and setting the for to a string property in my page model.  The Get is working fine with displaying the value in the model but when I save the form, in the post the for value is null.  Any ideas on how to get this to work?

Razor Page

<kendo-radiogroup for="Input.OwnOrRentId"
    label-position="RadioGroupLabelPosition.Before"
    layout="RadioGroupLayout.Horizontal" bind-to="Model.OwnOrRentItems">
</kendo-radiogroup>

 

Code behind

  [BindProperty]
   public InstallerPageModel Input { get; set; }

 

 public List<IInputGroupItem> OwnOrRentItems { get; set; }
 
        OwnOrRentItems = new List<IInputGroupItem>()
        {
            new InputGroupItemModel()
            {
                Label = OwnOrRentOptions.Own.GetDescription(),
                Value = OwnOrRentOptions.Own.NumericValue().ToString(),
                Enabled = true,
                CssClass = "green",
                Encoded = false,
                HtmlAttributes = new Dictionary<string,object>() { { "data-custom", "custom" } }
            },
            new InputGroupItemModel()
            {
                Label = OwnOrRentOptions.Rent.GetDescription(),
                Value = OwnOrRentOptions.Rent.NumericValue().ToString(),
                Enabled = true,
                CssClass = "green",
                Encoded = false,
                HtmlAttributes = new Dictionary<string,object>() { { "data-custom", "custom" } }                   
            }
        };
 
   public class InputGroupItemModel :IInputGroupItem
   {
    public IDictionary<string, object> HtmlAttributes { get; set; }
 
    public string CssClass { get; set; }
 
    public bool? Enabled { get; set; }
 
    public bool? Encoded { get; set; }
 
    public string Label { get; set; }
 
    public string Value { get; set; }
   }

 

 

Veselin Tsvetanov
Telerik team
 answered on 23 Apr 2021
1 answer
149 views

I have following DropDownListFor in a grid column

@{
    var selecItems = Enum.GetValues(typeof(Something)).OfType<Something>().Select(item => new
    {
        Text = item.Localize(),
        Value = item
     });
}
@(Html.Kendo().DropDownListFor(m => m)
            .DataTextField("Text")
            .DataValueField("Value")
            .BindTo(selecItems))

on the following column I have a MultiSelectFor. When user select an option from DropDownListFor must change MultiSelectFor datasource. Its possible?

Ianko
Telerik team
 answered on 22 Apr 2021
Narrow your results
Selected tags
Tags
+? more
Top users last month
Miljana
Top achievements
Rank 2
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Bronze
Cynthia
Top achievements
Rank 1
John
Top achievements
Rank 1
Iron
Mozart
Top achievements
Rank 1
Iron
Veteran
Want to show your ninja superpower to fellow developers?
Top users last month
Miljana
Top achievements
Rank 2
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Bronze
Cynthia
Top achievements
Rank 1
John
Top achievements
Rank 1
Iron
Mozart
Top achievements
Rank 1
Iron
Veteran
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?