Telerik Forums
UI for ASP.NET MVC Forum
5 answers
463 views
Here is the scenario:I have an ASP.Net MVC 4 application, using Kenod grids and toolbars from Telerik UI for ASP.Net MVC. There is a main grid with a Client Detail template defined. The template contains a toolbar, and each tab opens a Kendo grid which takes the primary key from the parent grid. All of these grids are editable, all but one opening a template view. It is the "all but one" where I am having issues that I hope you can help with.Here is the code for this one grid. Instead of being Editable, it has a custom Toolbar defined with a button:items.Add().Text("Linked Files").Content(obj =>
         Html.Kendo().Grid<MedSouth.Models.LinkedFilesModel>()
        .Name("LinkedFilesGrid#=PkPacketID#")
        .Sortable()
        .Scrollable()
        .Filterable()
        .Columns(columns =>
        {
            columns.Command(command => { command.Edit(); command.Destroy(); }).Width(130);
            columns.Bound(e => e.PkLinkedFilesID).Width(130).Hidden(true);
            columns.Bound(e => e.FkPacketID).Width(130).Hidden(true);
            columns.Bound(e => e.FileName)
                .Width(100)
                .Title("Download File")
                .Sortable(false)
                .Filterable(false)
                //.ClientTemplate((@Html.ActionLink("Download File", "Download", "LinkedFiles", new { ID = "#=PkLinkedFilesID#" }, null).ToHtmlString()))
                ;
            columns.Bound(e => e.FileName).Width(130);
            columns.Bound(e => e.FileDescription).Width(175).Title("Description");
            //columns.Bound(e => e.FileURL).Width(300);
        })
        .ToolBar(tb =>
        {
            tb.Template(@<text>
                        <div >
                            <a class="k-button" href="\\#" onclick="return toolbar_click()">Add File</a>
                        </div>
                    </text>);
        })
        .DataSource(dataSource => dataSource
                .Ajax()
                .PageSize(5)
                .Model(model => model.Id(e => e.PkLinkedFilesID))
                    .Read(read => read.Action("LinkedFiles_Read", "LinkedFiles", new { FkPacketID = "#=PkPacketID#" }))
                    //    .Read(read => read.Action("LinkedFiles_Read", "LinkedFiles"))
                    .Update(update => update.Action("LinkedFiles_UpdateWithReplace", "LinkedFiles"))
                    .Destroy(destroy => destroy.Action("LinkedFiles_Destroy", "LinkedFiles"))
                    .Create(create => create.Action("LinkedFiles_Create", "LinkedFiles", new { PkPacketID = "#=PkPacketID#" }))
        )
        .ToClientTemplate()
);Here is the Javascript associated with the button. It opens an aspx page in containing a file upload control - <input name="files" id="files" type="file" runat="server" />. This allows the user to select a file and save information to the database. This data will then be displayed in the LinkedFiles grid defined above.<script type="text/javascript">    function toolbar_click() {
         console.log("Toolbar command is clicked!");
        ShowReport();
        return false;
    }    function ShowReport(e) {        var grid = $("#LinkedFilesGrid").data("kendoGrid");
        var dataItem = grid.dataItem($(e.currentTarget).closest("tr"));
        alert(e);        var id = dataItem.FkPacketID;
        var u = "/Test.aspx?ID=" + id;
        alert(u);
        kendoWindow = $("#window2").data("kendoWindow");
        kendoWindow.refresh({ url: u });
        kendoWindow.center();
        kendoWindow.open();
    }</script>In a test application, this all works fine, apart from having to hard-code the PkPacketID in the Javascript function, where the variable "id" is hard-coded.When the parent grid detail is opened, the grid sees the ID defined in the grid name - "LinkedFilesGrid#=PkPacketID#" correctly and attempts to populate the grid with matching records.Currently there are no records available to load into this grid, so step one is to click the "Add File" button, which needs to find and pass the PkPacketID to the aspx page.This is the first issue: I cannot find that ID. Tha Javascript in "ShowReport" errors with "Cannot read property 'dataItem' of null" - it is not seeing the grid containing the "Add File" button, whether the grid contains data or not.Question: How do I get the PkPacketID that is defined in the grid name?



Thanks for your help.
Stephen
Stephen
Top achievements
Rank 1
 answered on 16 Apr 2015
2 answers
157 views

I found out that defining "Editable(false)" for a model field doesn't seem to work when I've chosen GridEditMode.PopUp:

@(Html.Kendo().Grid<Pharmacy>()
    .Columns(columns => ...)
    .Editable(editable => editable.Mode(GridEditMode.PopUp))
    .DataSource(dataSource => dataSource
        .Ajax()
        .Model(model =>
        {
            model.Id(p => p.Id);
            model.Field(p => p.Id).Editable(false);
            model.Field(p => p.MyReadOnlyField).Editable(false);
        }))
)

In this case, the "Id" field and the "MyReadOnlyField" field will be shown in the popup as editable - which obviously is not the expected behavior.

Is this done intentional or is it a bug that Model definition doesn't work correctly with PopUp edit mode? Of course I can define a custom template, but that's not what I really want... from my view it's a bug or missing feature.

 

Thanks in advance,
Dimitrij

 

Dimitrij
Top achievements
Rank 1
 answered on 16 Apr 2015
1 answer
464 views

Does ASP.NET MVC scheduler support integration with google calender or outlook?

Thank you..

Vladimir Iliev
Telerik team
 answered on 16 Apr 2015
2 answers
171 views
Is there any property that will put the calendar button to the left of the input, or hide the button altogether so I can use Bootstrap's input-group feature?
Scott
Top achievements
Rank 1
 answered on 16 Apr 2015
1 answer
117 views

Hi,

I'm Thinking of moving from kendo ui html5 to the mvc version but I am worried about performance problem when moving to large scale (2,000,000 + users per month) 

Has anybody experienced issues with the MVC edition of kendo that might not happen in the Kendo UI html5 version? 

 

Thanks

Kiril Nikolov
Telerik team
 answered on 16 Apr 2015
3 answers
2.8K+ views

Hi

please i have create my grid and set bootstrap theme to it and add 3 custom button on it and every thing works fine but buttons not centered in each grid cell it's align to right (i have add rtl css) as you can see in attached image

 so please how can i set them center vertically and Horizontally in each grid cell ?

Ahmed
Top achievements
Rank 2
 answered on 16 Apr 2015
2 answers
170 views

my attempt (Where I have Kendo DropDownList 1 as #Type and Kendo DropDownList 2 as #Units:

            $('#Type').change(function (e) {
                //if (e.target.value == "Electirc") {
                var val = e.target.value;
                var ddL = $('#Units').data("kendoDropDownList")

                if (val == "Electric") {
                    ddl.dataSource.data({Text:"-", value:"null"},{Text:"kW", value:"kW"},{Text:"GJ", value:"GJ"})
                    //$("#Units").html("<option value='null'>item1:-</option><option value='kW'>item1: kW</option><option value='GJ'>item1: GJ</option>");
                } 
            })

The goal would be to have the contents of DDL2 to change based on the selection by DDL1

Kiril Nikolov
Telerik team
 answered on 16 Apr 2015
1 answer
389 views

I'm starting to build a Telerik UI for ASP.NET MVC project, just like the Grid Demo on http://demos.telerik.com/aspnet-mvc/

And i got this error when i debug project.

What problem?

Vladimir Iliev
Telerik team
 answered on 16 Apr 2015
2 answers
114 views

I am using UI for MVC 2015.1.318

I am replacing user admin lists with Telerik grids, but need to call the original views for CRUD.  I have reviewed the documentation at http://docs.telerik.com/kendo-ui/aspnet-mvc/helpers/grid/server-editing as well as several forum posts, but the Edit command button always calls the inline editor.

 My grid

@(Html.Kendo().Grid(Model.UsersList)
    .Name("grid")
    .Columns(columns =>
    {
        columns.Bound(u => u.DisplayName);
        columns.Bound(u => u.AccountName);
        columns.Bound(u => u.Email);
        columns.Command(command => { command.Edit(); command.Destroy(); }).Width(200);
    })
    .Editable(editable => editable.Mode(GridEditMode.InLine))
    .Pageable()
    .Sortable()
    .Scrollable()
    .DataSource(dataSource => dataSource
        .Ajax()
        .ServerOperation(false)
        .PageSize(20)
        .Sort(sort => sort.Add("AccountName").Ascending())
        .Model(model => model.Id(u => u.UserId))
        .Update(update => update.Action("Edit", "UserAdmin"))
        .Destroy(destroy => destroy.Action("Delete", "UserAdmin"))
    )
)

There is a UserAdminController.cs with Edit and Delete methods.  Here is the Edit: 

public async Task<ActionResult> Edit(string id)
{
    if (id == null)
    {
        return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
    }
    var editUser = await UserManager.FindByIdAsync(id);
    if (editUser == null)
    {
        return HttpNotFound();
    }
 
    UserDetailsViewModel vm = new UserDetailsViewModel()
    {
        Id = editUser.Id,
        Email = editUser.Email,
        DisplayName = editUser.DisplayName,
        SelectedAccountId = editUser.AccountId,
    };
 
    // System Admins can assign Account to users, so get a list
    if (User.IsInRole("System Admin"))
    {
        vm.AvailableAccounts = DataRepo.GetAccountListForDdl().ToList();
    }
 
    await Edit_SetupRoles(editUser.Id, vm);
 
    vm.ProviderId = editUser.ProviderId;
    if (editUser.ProviderId != null)
        vm.ProviderName = DataRepo.GetProviderName(editUser.ProviderId);
 
    vm.AccessLevelsAssigned = DataRepo.GetAssignedUserAccessLevels(editUser.Id);
    vm.AccessLevelsPool = DataRepo.GetAvailableUserAccessLevels(editUser.Id, editUser.AccountId);
    vm.AccountAndClients = DataRepo.GetAccountAndClientListForDdl(editUser.AccountId).ToList();
    return View(vm);
}

Where is this going off the rails?

Best,
Scott

Scott Buchanan
Top achievements
Rank 1
 answered on 16 Apr 2015
10 answers
393 views
I apologize up front if there is an obvious answer to this question, but how do I persist the changes that a user makes to the nodes in a tree control when .DragAndDrop(true) is specified?  Since the MVC wrappers using a ReadOnly datasource, I'm really not sure how to do that other than starting to look into doing it outside the MVC wrappers.

Thanks,
Kyle
Laurie
Top achievements
Rank 2
 answered on 15 Apr 2015
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
MultiColumnComboBox
Dialog
DropDownTree
Checkbox
Slider
Switch
Notification
Accessibility
ListView (Mobile)
Pager
ColorPicker
DateRangePicker
Security
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
SegmentedControl
+? more
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?