Telerik Forums
UI for ASP.NET MVC Forum
0 answers
309 views

Try to use the Drag and Drop to reorder the rows. 
I'm stuck in an error that I'm not figuring out.

The error: Uncaught TypeError: Cannot read property 'insert' of undefined

The line: grid.datasource.insert(newIndex, dataItem );

I'm sure the datasource has data, since the "console.log(dataItem)" returns the object model


var Material = new kendo.data.Model.define({
    id: "NR_position",
    fields: {
        NR_position: { type: "number" },
        CD_Material: { type: "number" },
        NM_Material: { type: "string" }
    }
});

var Controller = {
    dataSource: {        
        ListMat: new kendo.data.DataSource({
            transport: { read: { url: matList, type: "POST" } },
            model: Material,             
            dataType: "json",
            url: "data/person.json"
        })
    },
    init: function () {
        var grid = $("#grdMatOrder").kendoGrid({
            dataSource: Controller.dataSource.ListMat,
            columns: [
                { field: "NR_position", title: "Order" },
                { field: "CD_Material", title: "Code" },
                { field: "NM_Material", title: "Name" }
            ]
        }).data("kendoGrid");

        grid.table.kendoSortable({
            filter: ">tbody >tr",
            hint: function (element) {
                var table = $('<tr colspan=4" class="placeholder></ tr>'), hint;

                table.append(element.clone());
                table.css("opacity", 0.7)                

                return table;
            },

            change: function (e) {
                var skip = grid.dataSource.skip(),
                    oldIndex = e.oldIndex + skip,
                    newIndex = e.newIndex + skip,
                    data = grid.dataSource.data(),
                    dataItem = grid.dataSource.getByUid(e.item.data("uid"));

                console.log(dataItem)

                grid.dataSource.remove(dataItem);
                grid.datasource.insert(newIndex, dataItem );
            }
        });
    }
};


$(document).ready(function () {
    Controller.init();
});

        


        

anna
Top achievements
Rank 1
 asked on 09 Jul 2021
1 answer
4.6K+ views

I have a kendo grid and in the create action, I want to post back the content of another grid's data source to a razor pages server.

@(Html.Kendo().Grid<EntityModel>() .Name("mainGrid") .DataSource(ds => ds.Ajax() .Read(r => r.Url("/Index?handler=ReadEntity")) .Create(c => c.Url("/Index?handler=CreateEntity").Data("getData")) .Model(m => m.Id(id => id.EntityID)) ) ) function getData() { var otherModels = $("#otherGrid").data("kendoGrid").dataSource.data(); var temp = $.extend(true, {}, kendo.antiForgeryTokens(), { otherModels: otherModels }); return temp; }

The result looks like this

temp

  • otherModels
    • 0
      • Name: xyz ...

       

The action:

public JsonResult OnPostCreateEntity(List<OtherViewModel> otherModels, [DataSourceRequest] DataSourceRequest request, EntityViewModel entityModel) //otherModels is empty

This works fine for collections of simple objects like integers, but in this case, an exception is thrown:

"Cannot read property 'field' of undefined"

Anton Mironov
Telerik team
 answered on 08 Jul 2021
1 answer
525 views

Hello, I have a grid which uses popup editing, and inside the editor is another grid which uses incell-editing. This basically works, apart from the following:

For the nested grid, I want to use an editor template, containing a multiselect.

But on editing a cell with the editor template, nothing happens. What might be the reason for this?

Main Grid:

@(Html.Kendo().Grid<WorkspaceViewModel>()
            .Name("grid")
            .Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("WorkspaceDialog"))
            .ToolBar(x => x.Create().Text("Add Workspace"))
            .Columns(columns =>
            {
                columns.Bound(column => column.Name);
                columns.Command(column =>
                {
                    column.Edit().UpdateText("Save");
                    column.Destroy();
                }).Width(230);
            })
            .DataSource(ds => ds.Ajax()
                .Read(r => r.Url("/Workspaces/Index?handler=ReadWorkspace").Data("getSearchParameters"))
                .Update(u => u.Url("/Workspaces/Index?handler=UpdateWorkspace").Data("getSelectedReports"))
                .Create(c => c.Url("/Workspaces/Index?handler=CreateWorkspace").Data("getSelectedReports"))
                .Destroy(d => d.Url("/Workspaces/Index?handler=DestroyWorkspace").Data("forgeryToken"))
                .Model(m => m.Id(id => id.WorkspaceID))
                .PageSize(10)
            ) )

Popup:

<div class="k-edit-field">
    @(Html.Kendo().Grid<ViewModels.ReportUserViewModel>()
        .Name("reportGrid")
        .Columns(columns =>
        {
            columns.Bound(column => column.Name);
            columns.Bound(c => c.SelectedUsers) //List<UserSelectViewModel>
                .ClientTemplateId("reportUserTemplate")
                .Sortable(false)               
                .EditorTemplateName("~\\/Views\\/Shared\\/EditorTemplates\\/UserSelect.cshtml")
        })
        .Editable(editable => editable.Mode(GridEditMode.InCell))
        .DataSource(ds => ds
            .Ajax()
            .Read(r => r.Url("/Workspaces/Index?handler=ReadReport").Data("getSelectedReportUsers"))
            .Model(m => m.Id(id => id.ReportID))
            .PageSize(10)
            .ServerOperation(false)
        )
    )
</div>

Editor Template:

@model List<ViewModels.UserSelectViewModel>

@(Html.Kendo().MultiSelectFor(m => m)
    .AutoBind(false)
    .DataTextField("Name")
    .DataValueField("UserID")
    .BindTo((List<UserSelectViewModel>)ViewData["Users"])
    )

The controls are inside a Razor Pages application. Both templates are placed in the Views/Shared/EditorTemplates folder. In the Editor Template markup, I tried to use the absolute path to the view, because EditorTemplates("UserSelect") threw some error ("Unexpected token").

Everything works fine if I use the Multiselect in the main grid.

Jan-Frederik
Top achievements
Rank 1
Iron
Iron
 updated question on 06 Jul 2021
1 answer
204 views

Hi

I have successfully found a way to make the resource horizontal grouping headers have a div with several elements inside, and custom styling. 

I need this to add a portrait of people, their names and an apartment name, for each of the resource group headers.

However if i have 16+ columns to show in the horizontal view, it gets squished together, so there isn't enough space to see the details.

SO, i set the widths of each of the headers to 200px, and add them together and add the width to the this.view().table[0] 's styles. This works for the headers.... However, the horizontal scrollbar doesn't appear, and the events dont match anymore. So when i call any "refresh", "rebind", "resize" etc. method, the site crashes because it creates an infinite loop. 

What can i do?

Js databound function:

function hideStaffTimeHeader() {
	var view = this.view();

	// remove the times header row
	var trs = view.timesHeader[0].children[0].children[0].children;
	for (var i = 1; i < trs.length; i++) {
		trs[i].remove();
	}
	$(".k-scheduler-header-wrap > table > tbody > tr:eq(1)").hide();

	// attempt to set the width of each header and total width of entire table.
	var columns = view.table[0].children[0].children[0].children[1].children[0].children[0].children[0].children[0].children[0].children;
	var width = 0;
	for (var i = 0; i < columns.length; i++) {
		columns[i].style.width = "200px";
		width += 200;
	}
	view.table[0].style.width = width + "px";
}

 

the mvc razor cshtml:


@model IList<WebStaffScreen.Models.TaskViewModel>
@using Kendo.Mvc.UI

<div id="sc_container">
@(Html.Kendo().Scheduler<WebStaffScreen.Models.TaskViewModel>()
		.Name("staffCalender_scheduler")
		.DateHeaderTemplate("<span class='k-link k-nav-day'>#=kendo.toString(date, 'dd-MM-yyyy')#</span>")
		.Date(DateTime.Now)
		.AllDaySlot(false)
		.Editable(e => e.TemplateName("StaffEditorPartialView"))
		.Views(v => v.DayView(d => d.Selected(true)))
		.Group(group => group.Resources("CitizenManagerName").Orientation(SchedulerGroupOrientation.Horizontal))
		.Resources(res => res.Add(m => m.CitizenManagerID)
			.Name("CitizenManagerName")
			.DataTextField("FullName")
			.DataValueField("ID")
			.DataSource(s => s.Read(r => r.Action("GetCitizenManagersInResidence", "StaffCalendar")))
		)
		.DataSource(d => d.Model(m => m.Id(f => f.TaskID))
			.Read("Read", "StaffCalendar")
			.Create("Create", "StaffCalendar")
			.Update("Update", "StaffCalendar")
			.Destroy("Destroy", "StaffCalendar")
		)
		.Events(e => e.DataBound("hideStaffTimeHeader"))
)
</div>


 

Update:

Heres a sample with the problem, and some Readme info in the Home/index page .. 

 

Attila
Top achievements
Rank 1
Iron
Iron
 updated question on 05 Jul 2021
1 answer
661 views

I'm trying to use the Kendo Datepickerfor in an MVC application that doesn't allow past dates to be selected. If we use .Min or .DisableDates then the input doesn't display the date from the Model.

I've tried a workaround with using a template to set the past dates as 'k-state-disabled' but couldn't get to a solid solution of disabling click events. It would work using the Open event, but when navigating in the calendar, it would still allow past dates to be selected.

Thoughts/help would be great.

Anton Mironov
Telerik team
 answered on 05 Jul 2021
2 answers
229 views

Hi,

I am trying to get the .InsertUnorderedList()  to set a bullet point for every line there is in the Editor. But it only does the first line. Anyone that knows how to change this behaviour?

I have attached a picture of this.

Thanks,

Mark

Mark
Top achievements
Rank 1
Iron
 answered on 05 Jul 2021
1 answer
782 views

Hi,

How can I save the results of all steps when filling in all the Wizard steps ?  (in Telerik Asp.Net MVC Wizard control)

Lets say that step 2 is dependant on step 1 (screen should be rendedered with/without certain controls dependant of what was filled in on step 1.

How can I achieve this ?

Is there a serverside 'Next' click event or so ? Or a Select step event or so ?  I havent seen it to my dissapointing surprise.

(I know I can load content tabs with Ajax, but that doesnt give me the entered data.)

Martin

 

Ivan Danchev
Telerik team
 answered on 02 Jul 2021
1 answer
3.4K+ views

Hello,

how can i send a id parameter on Onclick delete action javascript, this is my code. i don't want to use action link because i'm using ajax call

Thanks for helping.

 


@(Html.Kendo().Grid(Model)
            .Name("Conventions")
            .Columns(columns => {
                columns.Bound(c => c.Libelle).Width("450px");
                columns.Bound(c => c.DateEnvoi).Format("{0:dd/MM/yyyy}");
                columns.Bound(c => c.Statut.Libelle).Title("Statut");
                columns.Template(@<text></text>).ClientTemplate("<span class='k-icon k-i-delete' id='deleteIcon'></span>").HtmlAttributes(new { onclick = "onDeleteConvention()" }).Width("40px");

            }).NoRecords("Pas de conventions trouvés")
            .Scrollable().Height(200).DataSource(dataSource => dataSource
                .Ajax()
                .PageSize(20)
                .ServerOperation(false)
                .Model(model =>
                {
                    model.Id(p => p.ConventionId);
                    model.Field(p => p.Libelle).Editable(false);
                    model.Field(p => p.DateEnvoi).Editable(false);
                    model.Field(p => p.Statut.Libelle).Editable(false);
                })
             )
            )

Ivan Danchev
Telerik team
 answered on 30 Jun 2021
1 answer
268 views

Hi,

I have a kendo grid with some thousands of records with employees.

so when i click new record in kendo grid, in new row first column is employee name. here am using employeename Edit template view to display employee inside kendo grid while editing.

so is there any possibility like i want to retrieve all the employees from grid and assign those values to dropdown list ( employeename Edit template view) instead of calling to DB.

Eyup
Telerik team
 answered on 30 Jun 2021
1 answer
166 views

Hi ,

I have a kendo grid which displays the all employees and their timesheets values. with sum aggregates in footer grid.

here is my requirement.

currently i am editing June month column of A person from the image shown.

in jQuery after getting A person records (using current cell and finding emp number of current row then am querying only that empnumber  to get  A person records) then i want to do sum of column of editing cell (june column).

but i dont want to apply any filters to grid. grid should display previous values only not to show only A person values.

 

Eyup
Telerik team
 answered on 30 Jun 2021
Narrow your results
Selected tags
Tags
Grid
General Discussions
Scheduler
DropDownList
Chart
Editor
TreeView
DatePicker
ComboBox
Upload
MultiSelect
ListView
Window
TabStrip
Menu
Installer and VS Extensions
Spreadsheet
AutoComplete
TreeList
Gantt
PanelBar
NumericTextBox
Filter
ToolTip
Map
Diagram
Button
PivotGrid
Form
ListBox
Splitter
Application
FileManager
Sortable
Calendar
View
MaskedTextBox
PDFViewer
TextBox
Toolbar
Dialog
MultiColumnComboBox
DropDownTree
Checkbox
Slider
Switch
Notification
Accessibility
ListView (Mobile)
Pager
Security
ColorPicker
DateRangePicker
Wizard
Styling
Chat
DateInput
MediaPlayer
TileLayout
Drawer
SplitView
Template
Barcode
ButtonGroup (Mobile)
Drawer (Mobile)
ImageEditor
RadioGroup
Sparkline
Stepper
TabStrip (Mobile)
GridLayout
Badge
LinearGauge
ModalView
ResponsivePanel
TextArea
Breadcrumb
ExpansionPanel
Licensing
Rating
ScrollView
ButtonGroup
CheckBoxGroup
NavBar
ProgressBar
QRCode
RadioButton
Scroller
Timeline
TreeMap
TaskBoard
OrgChart
Captcha
ActionSheet
Signature
DateTimePicker
AppBar
BottomNavigation
Card
FloatingActionButton
Localization
MultiViewCalendar
PopOver (Mobile)
Ripple
ScrollView (Mobile)
Switch (Mobile)
PivotGridV2
FlatColorPicker
ColorPalette
DropDownButton
AIPrompt
PropertyGrid
ActionSheet (Mobile)
BulletGraph
Button (Mobile)
Collapsible
Loader
CircularGauge
SkeletonContainer
Popover
HeatMap
Avatar
ColorGradient
CircularProgressBar
SplitButton
StackLayout
TimeDurationPicker
Chip
ChipList
DockManager
ToggleButton
Sankey
OTPInput
ChartWizard
SpeechToTextButton
InlineAIPrompt
TimePicker
StockChart
RadialGauge
ContextMenu
ArcGauge
AICodingAssistant
SmartPasteButton
PromptBox
SegmentedControl
LLM Kit
+? more
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?