Telerik Forums
UI for ASP.NET MVC Forum
4 answers
148 views

Hi:

From the server side, I can save the content of the editor for a .docx file indicating the path where I want to save it

 

Regards, Guillermo

Plamen
Telerik team
 answered on 01 Jan 2021
4 answers
1.4K+ views

Hey,

So i have a grid on my page which is going to act as a result view to search criteria input into the provided controls.

By default to grid does not make a request to obtain data on page load. .AutoBind(false) has been set.

So what i require is when the page is loaded the user will be presented with a range of inputs that will make up the "Search Filter", when the search button is clicked i create a complex object which is then passed to the controller and the filtering will happen in the IQueryable object. and this works without an issue.

The problem comes in when i try and page, filter, sort or change the page size the grid does not use my custom javascript function to pass the complex object as parameters to the controller, my parameters are only passed when i click on the search button.

i have read up on the grid events here

and i attached the .Sort(), .Filter(), .Page() events to my javascript  function, the problem is that then the grid makes  2 requests to the server, 1 request with a null parameter and another request with the parameter.

How do i disable the default grid Paging, Filtering,Sorting and Page Size change triggers and make it use my own javascript function so that even if i page, filter, sort the complex parameter object is passed to the controller every single time?

public class SystemLogsParameters
{
  public string Message { get; set; }
}

 

Controller

[HttpPost]
public ActionResult PopulateLogsGrid([DataSourceRequest] DataSourceRequest request, SystemLogsParameters Data)
{
  DataSourceResult result = new LogsGrid().PopulateSystemSettingLogsGrid(request,Data);
  return Json(result);
}

 

View

<div class="row">
    <input type="text" id="tbMessage" placeholder="Message" />
</div>
 
<div class="row">
    @(Html.Kendo().Grid<Presentation.GenericGridViewModel>()
        .Name("Grid")
        .AutoBind(false)
        .Events(ev => ev
 
            .Sort("loadGrid") <-- Makes 2 requests to server
            .Filter("loadGrid") < --Makes 2 requests to server
            .Group("loadGrid") < --Makes 2 requests to server
            .Page("loadGrid")) < --Makes 2 requests to server
 
         .Columns(columns =>
         {
             columns.Bound(o => o.Name);
             columns.Bound(o => o.LastUpdated).Format("{0: dd MMM yyyy HH:mm}");
             columns.Bound(o => o.Active);
             columns.Bound(o => o.Id).ClientTemplate("<img class='grid-button gb-update' src='../Images/icons/update.png' onclick='update(#=Id#)' title='Update' />" +
             "#if(Active){#<img class='grid-button gb-delete' src='../Images/icons/delete.png' onclick='deactivate(#=Id#)' title='Delete' />#}#")
             .Width(100)
             .Title("Actions")
             .Filterable(false)
             .Sortable(false)
             .Groupable(false);
         })
        .NoRecords("No logs found.")
        .ToolBar(toolbar =>
        {
            toolbar.Template("<a class='k-button k-primary' onclick='Add()' href='javascript:;'><i class='fa fa-plus'></i>  Add</a>");
        })
        .Pageable(pager => pager.AlwaysVisible(true).ButtonCount(5).PageSizes(new List<object>{ 5, 10, 20, 100 }))
            .Sortable()
            .Filterable()
            .Scrollable(a => a.Height("auto"))
        .DataSource(d => d
            .Ajax()
            .Model(a => a.Id(p => p.Id))
            .Read(read => read.Action("PopulateLogsGrid", "Setting"))
            .PageSize(20)
        ))
 
</div>
<div class="row">
    <input type="button" onclick="loadGrid()" value="Submit" />
</div>
 
 
<script>
 
 
    function loadGrid() {
 
        var myParameters = { "Message": $("#tbMessage").val() };
 
        var grid = $('#Grid').data('kendoGrid');
        grid.dataSource.read({ Data: myParameters });
    }
 
</script>
Ravi
Top achievements
Rank 1
 answered on 31 Dec 2020
3 answers
7.1K+ views

I would like to conditionally disable custom command button when a specific value existing in a column field.

@(Html.Kendo().Grid<Swisslog.DC.Entities.AlarmRespond>
                ()
                .Name("alarmRespondGrid")
                .Events(e => e.DataBound("commandButtons"))
                .Columns(columns =>
                {
                    columns.Bound(c => c.Customer).Title("Customer");
                    columns.Bound(c => c.CustomerID).Title("Customer #").Sortable(false).Width(100);
                    columns.Bound(c => c.EquipmentID).Title("Equipment #").Sortable(false).Width(100);
                    columns.Bound(c => c.AlarmCode).Title("Alarm").Sortable(false).Width(75);
                    columns.Bound(c => c.AltAlarmDescription).Title("Description").Sortable(false);
                    columns.Bound(c => c.FirstAlarmDateLocal).Title("Alarm Date").Format("{0:MM/dd/yy hh:mm:ss tt}").Width(175);
                    columns.Bound(c => c.AlarmCount).Title("Count").Sortable(false).Width(75);
                    columns.Bound(c => c.AssignedTo).Title("Assigned To").Sortable(false).Width(175);
                    columns.Command(command => command.Custom("Assign").Click("assignAlarm")).Width(100);
                    columns.Command(command => command.Custom("Auto Case").Click("showResolveWindow")).Width(100);
                    columns.Command(command => command.Custom("Manual Case").Click("createSfdcAlarmCase")).Width(100);
                })

 When c.AssignedTo == "" I would like to disable the Auto Case and Manual Case buttons.  It is not clear to me how to accomplish this with a custom command.

 

Jim

 

Ólafur Gíslason
Top achievements
Rank 1
 answered on 31 Dec 2020
1 answer
279 views

Hello;

I'm trying to use footer total in grid edit mode InCell for my grid. The total display correctly but I have to hit save/update button. Is it possible to auto/refresh calculate after I moved out of that cell or column without to hit the save button? Any advices. Thanks.

Nikolay
Telerik team
 answered on 31 Dec 2020
3 answers
1.0K+ views

I have implemented cascading drop down functionality using the following URL

https://github.com/telerik/ui-for-aspnet-mvc-examples/tree/master/grid/grid-editing-cascading-dropdownlist

Is there a way to display Text of the drop down in the grid cell instead of Id

earlier help is highly appreciated

 

Nikolay
Telerik team
 answered on 30 Dec 2020
2 answers
280 views
What do I need to configure to get this toggle button to show up on my Scheduler control using MVC? Consulting the sample code that generates this gives me no clues.
Responsive
Top achievements
Rank 1
Veteran
 answered on 29 Dec 2020
4 answers
2.9K+ views

Hello,

 

 

I  am working with telerik ui for asp.net mvc.

I have a textbox named path of poste.

By entering, it should show me the tree view of my local directories in a window.

when I select a directory, I need to show only the full path in my text box.

So i need to show the path of the selected folder from my local folders. How can I do this ?

Any help or suggestions please ?

Nikolay
Telerik team
 answered on 28 Dec 2020
1 answer
700 views

Hi,

I’m trying to use the filter component with dynamic datasource. (Asp.net MVC)
I'm writing something like this:
    @(Html.Kendo().Filter<dynamic>()
        .Fields(f =>
        {
            foreach (var field in Model.Fields)
            {
                f.Add().Label(field.Label).EditorTemplateHandler(“func”+field.type);            
            }
        }).FilterExpression(f =>
        {
            f.AddRange(Model.Filters);
        }))




For filters, I had to create my own conversion function (string json -> IFilterDescriptor) because I couldn't get the one used for the grids to work (= FilterDescriptorFactory.Create)

And now, I am blocked by the dynamic change of operators. These change depending on the type of field. However, I do not pass a field (because dynamic), and I do not have a "SetType" function as for "kendo-ui" (https://docs.telerik.com/kendo-ui/api/javascript/ui/filter/configuration/fields.type)

How can I do ?

Regards
P.S. I'm with v2020.3.915

Preslav
Telerik team
 answered on 24 Dec 2020
3 answers
2.0K+ views

I have a Kendo Editor which is defined as below:

@(Html.Kendo().Editor()
                    .Name("myEditor")
                    .Tag("div")
                    .Tools(tools => tools
                            .Clear()
                            .Bold()
                            .Italic()
                            .Underline()
                            .Strikethrough()
                            .JustifyCenter().JustifyFull().JustifyLeft().JustifyRight()
                            .CreateLink().Unlink().TableEditing().FontColor().BackColor())
                     .Value(@<text>
                                Hello Kendo Editor <some text with html tags here>
                        </text>)
                )

Then I have two buttons that show up only for the admins - Save and Edit, and they are defined as below -

<button type="button" id="btnedit">Edit</button>
 <input type="submit" name="btnSave"  id="btnSave" value="Save" class="btn btn-default" />

 

There are other two submit buttons on the form like below -

<input type="submit" name="btnAgree"  id="btnAgree"  value="Agree" class="btn btn-primary" />
<input type="submit" name="btnDisagree" id="btnDisagree" value="Disagree" class="btn btn-default" />

 

And the form handles the submit of Agree and Disagree buttons by using the BeginForm("ActionMethod", "Controller", FormMethod.Post) like below -

@using (Html.BeginForm("Index", "MyControllerName", FormMethod.Post))

 

Now I want that, when an admin user comes in and makes changes to the Editor text and hits 'Save' button, I want the text of the editor to get saved in database. I can handle the saving part. I just want to know, how can I get the text from the Kendo Editor and send the text value to the action method in the controller.  

I tried the solution provided in this thread here - http://www.telerik.com/forums/save-changes-to-and-print-content-of-editor-in-mvc

So, using the solution here I added an action method with the string argument name similar to the Editor name like below -

public ActionResult Save(string myEditor) {

// TO DO: Save the text to the database

 }

When I run my application, and hit 'Save' button, I get the below error - 

HTTP Error 404.0 - Invalid navigation
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.

It does not hit the 'Save' Action method. How can I get that working?

Thanks

Ivan Danchev
Telerik team
 answered on 23 Dec 2020
12 answers
416 views

While selecting an item from the dropdowntree control, items without children shows-up properly but those with child items don't have labels, including the child items. The <span class='k-in'> is empty, it is direct-child of <div class='k-bot'> which is under the <li role='treeitem'>.

I followed this example but omitted the second mapping because from the root parents to the children, they share the same structure. IEnumerable of my "TreeItem" class:

public class TreeItem<T>{

public T Item {get;set;}

public IEnumerable<TreeItem<T>> Children {get;set;}

public bool HasChildren {

get {

return this.Children != null && this.Children.Coun() > 0;

}

}

}

 

And here's how I configured the binding part:

@(Html.Kendo().DropDownTree()

.Name("Categories")

.BindTo(Model.CategoriesList, mapping => {

mapping.For<TreeItem<Category>>(binding => binding

.Children(c => c.Children)

.ItemDataBound((item, categ) => {

item.Expanded = true;

item.HasChildren = categ.HasChildren;

item.Id = categ.Item.Id;

item.Text = categ.Item.Name;

item.Value = categ.Item.Id.ToString();

})

)

})

.LoadOnDemand(false)

)

the Model.CategoriesList is IEnumerable<TreeItem<Category>> which makes it the same structure as the Children of the TreeItem<Category> in here, if it matters.

Petar
Telerik team
 answered on 22 Dec 2020
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?