Telerik Forums
UI for ASP.NET MVC Forum
1 answer
1.3K+ views

Hi,

I'm trying to pass a DateTime value (Start_Date) to an ActionResult used by a template, but seems it is always null (other arguments string and int format are ok), changing type from dateTime to string seems to work, the value is a not null datetime string version but I would like to use directly the datetime, any suggestion?

 

(index.cshtml)

            columns.Bound(p => p.Start_Date).Format("{0:dd/MM/yyyy}");
            columns.Template(@<text></text>).ClientTemplate(
                                    "<a href='" +
                                         Url.Action("Details", "Data_Values") +
                                         "/?ContactID=#=Contact_ID#&SerialNumber=#=Serial_Number#&StartDate=#=Start_Date#'" +
                                    ">Details</a>").Width("100px");

(controller Data_ValuesController)

public ActionResult Details(int? ContactID, DateTime? StartDate, String SerialNumber)
        {

[...]

 

Veselin Tsvetanov
Telerik team
 answered on 11 Nov 2019
2 answers
882 views

Hello,

I have the following grid:          

 

01.@(Html.Kendo()
02.      .Grid<FVM>()
03.      .Name("grid")
04.      .NoRecords("No records to show")
05.      .PersistSelection(true)
06.      .Columns(column =>
07.      {
08.          column.Select().Width(50);
09.          column.Bound(p => p.ID).Title("View").Width(50);/*.Hidden(true)*/;
10.          column.Bound(p => p.Mnemonic).HeaderHtmlAttributes(new { style = "overflow: visible; white-space: normal; text-align: right: " })/*.Hidden(true)*/;
11.          column.Bound(p => p.Name).HeaderHtmlAttributes(new { style = "overflow: visible; white-space: normal; text-align: right: " })/*.Hidden(true)*/;
12.          column.Bound(p => p.Country).HeaderHtmlAttributes(new { style = "overflow: visible; white-space: normal; text-align: right: " })/*.Hidden(true)*/;
13.          column.Bound(p => p.State).HeaderHtmlAttributes(new { style = "overflow: visible; white-space: normal; text-align: right: " })/*.Hidden(true)*/;
14.          column.Bound(p => p.City).HeaderHtmlAttributes(new { style = "overflow: visible; white-space: normal; text-align: right: " })/*.Hidden(true)*/;
15.          column.Bound(p => p.Region).HeaderHtmlAttributes(new { style = "overflow: visible; white-space: normal; text-align: right: " })/*.Hidden(true)*/;
16.          column.Bound(p => p.District).HeaderHtmlAttributes(new { style = "overflow: visible; white-space: normal; text-align: right: " })/*.Hidden(true)*/;
17.          column.Bound(p => p.Address).HeaderHtmlAttributes(new { style = "overflow: visible; white-space: normal; text-align: right: " }).Hidden(true);
18.          column.Bound(p => p.Latitude).HeaderHtmlAttributes(new { style = "overflow: visible; white-space: normal; text-align: right: " }).Hidden(true);
19.          column.Bound(p => p.Longitude).HeaderHtmlAttributes(new { style = "overflow: visible; white-space: normal; text-align: right: " }).Hidden(true);
20.      })
21.      .Sortable()
22.      .Filterable()
23.      .Pageable()
24.      .Reorderable(r => r.Columns(true))
25.      .ColumnMenu()
26.      .DataSource(dataSource => dataSource
27.        .Ajax()
28.        .PageSize(10)
29.        .Model(m => m.Id(p => p.ID))
30.        //.ServerOperation(false)
31.        .Read(read => read.Action("FacilityProfile", "Facilities", new { Area = "AccountSettings" }))
32. ))

 

When you press a button, the items that you have selected will be sent to the controller. Also, on filter the selected items persist. My problem is that if you have items from more than one page selected only the items from the current page will be sent to the controller. Is there a way to fix this? Thanks!

 

Here is the button:

1.@(Html.Kendo().Button()
2.      .Name("SaveButton")
3.      .Content("Save")
4.      .Icon("save")
5.      .HtmlAttributes(new { type = "button" })
6.      .Events(e => e.Click("SaveMyFacilities")))

 

And Here is how I'm getting the selected rows:

1.var grid = $("#grid").data("kendoGrid");
2.var selectedRows = grid.select();
3.var list = new Array;
4.selectedRows.each(function (index, row) {
5.    var selectedItems = grid.dataItem(row);
6.    list.push(selectedItems.ID);
7.})
Tsvetomir
Telerik team
 answered on 11 Nov 2019
5 answers
1.3K+ views

Hi, I'm trying restrain the Multiselect to a max-height and have it show a scroll bar display inside the multiselect if the amount of values selected would exceed the max height of the display area.  Nothing I've tried so far has worked though.  Is this possible?  If so, how can I do that?

 

To be clear I'm not talking about the dropdown list that appears when the user selects items, I'm talking about after the items have been selected in the main box area.

 

Thanks

 

Mike

Christopher
Top achievements
Rank 1
 answered on 08 Nov 2019
2 answers
879 views

We have a listview bound to a collection of images. It's set to single select. We handle onChange() to get the name of the image file and write this to a textfield (id = "ImageFile"):

        function onChange(arg) {
            var selected = $.map(this.select(), function (item) {
                return $(item).text();
            });

            $("#ImageFile").val(selected[0].trim());
        }

In order to effectively cancel the selection we provide a hyperlink (id="clearImage") next to the text field and handle it's click method:

        // clears the value in the Image text field
        $("#clearImage").bind("click", function (e) {
            e.preventDefault();
            $("#ImageFile").val("");
        });

Is there a way to clear the listview of any selection (the orange background) from clearImage.click() ? 

Alternatively can the second click of a selected item in the listview deselect it? A toggle() type function that will select/deselect? 

Is there a function to pre-select an item in the listview? So on an Edit record screen I would select the item in the listview as it is loaded that the user selected on the Add screen of the record? 

Hoping we can get rid of the ImageFile text field and handle select/deselect in the ListView itself.

Thank you,

Simon

 

Simon
Top achievements
Rank 1
 answered on 08 Nov 2019
2 answers
378 views

Hello,

I am new to using the Grid and need a little help.

I have a ViewModel for my page, for brevity's sake, say the model has an EventName for display, and a List of EventRegistrations, and a couple of text boxes to capture data.  Using Razor on the view.

I am populating the grid in an Ajax call - but I am not updating any of the grid records.  Can I populate it from the ViewModel when the page loads? 

Secondly... I am using the grid to add a checkbox to each row.  I want to be able to access these selected values server-side and I do not know how to do this so that I can HttpPost to my controller all of the grid rows with the selected rows along with the couple of other textbox values I'll be using.  I have seen the .Columns.Select() approach and the ClientTemplate javascript approach.  

I usually depend on the ViewModel to be there in the post -- but I am not sure how to get values from the View's ViewModel and the KendoGrid.

I just need a little assistance getting in the right direction.

Thank you for assistance in advance,

Therese

Viktor Tachev
Telerik team
 answered on 07 Nov 2019
2 answers
683 views

The new filter is what I have been waiting for - thank you. However, I have created a custom editor as I want to search for a number in an id field, i.e. 922 instead of "922". I am using the following:

 function RiskIdEditor(container, options) {
  $('<input data-bind="value: value" name="' + options.field + '"/>')
   .appendTo(container)
   .kendoNumericTextBox();
 }

but this defaults to include 2 decimal places, e.g. 922.00. How do I force the numeric text box to display whole numbers only?

Thanks,

Jonathan

Viktor Tachev
Telerik team
 answered on 04 Nov 2019
3 answers
359 views

I have a number of projects that have anchor tags that use code similar to <a href="javascript:$('#window').data('kendoWindow').open()">open</a> to open kendo windows.  I have recently gotten reports that users are getting an error using that link in firefox.  It appears to try to navigate to $('#window').data('kendoWindow').open().

If i change this to put $('#window').data('kendoWindow').open() into a separate function and call that from the Javascript function it appears to work.  The problem is that i have followed this paradigm in many projects over the year.

You can see am example at https://dojo.telerik.com/IWAKIjom/2

 
Ivan Danchev
Telerik team
 answered on 04 Nov 2019
1 answer
180 views

In the attached below, I don't want an Empty to be dragged to another Empty.   But anything else is allowed.

Is there an undo event?

Thanks

Tsvetomir
Telerik team
 answered on 04 Nov 2019
1 answer
588 views

I have multiple dropdown fields on a form.The form might start off with 3 fields, I want the user to be able to add extra dropdown fields (see the attached screenshot). Lets say the customer currently has 3 machines but has just bought a fourth one. I display the company document showing the three machines, the user presses the + button to create a new entry and then selects the correct machine from the dropdown. I have the copying of the field working, the problem is that the DropDownList ist not getting populated i.e. the .read of the datasource is not being called (at least that is what I think is happening). I assume I need to call the init (.kendoAutoComplete) function somehow, cannot figure out how though. Any pointers would be great!

 

Here the DropDownField I am trying to copy: 

@(Html.Kendo().DropDownList()
      .Name(kendoFieldName)
      .MinLength(3)
      .Value(Model.Fields[i].Values[j])
      .HtmlAttributes(new {style = "width: 100%"})
      .Filter(FilterType.Contains)
      .DataSource(source =>
      {
          source.Read(read =>
          {
              read.Action("TypeAhead", "Document", new
              {
                  docId = Model.DocId,
                  docType = Model.DocType,
                  fieldNumber = Model.Fields[i].FieldIndex,
                  row = j,
                  currentValue = Model.Fields[i].Values[j]
              });
          })
          .ServerFiltering(true);
      })
      )

 

The clone button is:

<button id="plusButton" type="button" class="btn" onclick="addRow(@i, @j, @Model.Fields[i].Values.Count);">
    <i class="fa fa-plus fa-lg"></i>
</button>

 

And finally the addRow function:

//
// Add a new div to the page
//
var newRowNumber = 0;
 
function addRow(field, value, numberOfValues) {
 
    var rowId = `row_field_${field}_value_${value}`;
    var fieldId = `field_${field}_value_${value}`;
    var originalFieldId = `original_field_${field}_value_${value}`;
    var newRowId = `row_field_${field}_value_${numberOfValues + newRowNumber}`;
    var newFieldId = `field_${field}_value_${numberOfValues + newRowNumber}`;
    var newFieldName = `Fields[${field}].Values[${numberOfValues + newRowNumber}]`;
    var addFunction = `addRow(${field}, ${numberOfValues + newRowNumber}, ${numberOfValues})`;
    var removeFunction = `removeRow('${newRowId}')`;
 
    // get the current row
    const currentRow = $(`#${rowId}`);
    if (!currentRow.length) return;
 
    newRowNumber++;
 
    // clone the row
    var newRow = currentRow.clone();
    newRow.attr("id", newRowId);
 
    // update the value field
    var newField = newRow.find(`#${fieldId}`);
    newField.val("");
    newRow.find(`#${fieldId}`).attr({ name: newFieldName });
    newRow.find(`#${fieldId}`).attr({ id: newFieldId });
    newRow.find(`#${fieldId}`).attr({ value: "" });
 
    // remove the stuff you don't need
    newRow.find(`#${originalFieldId}`).remove();
    newRow.find("#minusButton").remove();
    newRow.find("#plusButton").remove();
    newRow.find("#labelForField").remove();
 
    // add minus button
    var plusButton = `<button id="plusButton" type="button" class="btn" onclick="${addFunction};"><i class="fa fa-plus fa-lg"></i></button>`;
    var minusButton = `<button id="minusButton" type="button" class="btn" onclick="${removeFunction};"><i class="fa fa-minus fa-lg"></i></button>`;
    newRow.find("#buttons").append(plusButton);
    newRow.find("#buttons").append(minusButton);
     
    // add the new row
    $(currentRow).after(newRow);
 
}
//
// remove a div on the age
//
function removeRow(rowId) {
 
    // get the current row
    // need to add the trim here as using template strings above added a extra space to the literal? see removeFunctions(" values")
    const currentRow = $(`#${rowId.trim()}`);
    if (!currentRow.length) return;
 
    // remove the row
    currentRow.remove();
 
}

 

 

 

 

Ursus
Top achievements
Rank 1
Iron
 answered on 03 Nov 2019
6 answers
1.6K+ views
i'm trying to show value labels at top of the my chart's columns. I use Kendo UI.I find this example but i havent done it.

It's example:
http://jsfiddle.net/8YnKv/31/


How can i show 100 and 20 values like in the example chart?

I have tried this code but i failed.

 .Labels(labels => labels
.Visible(true).Format("C").Position(ChartBarLabelsPosition.OutsideEnd)
)


Here is my chart code. What can i do?
How can i add this functionality?
Thanks for your help. 


@(Html.Kendo().Chart(Model.TarihVM)
.Name("chart")
.Title(title => title
.Text("my chart title")
.Position(ChartTitlePosition.Top))
.Legend(legend => legend
.Visible(true)
.Position(ChartLegendPosition.Top))
.Series(series =>
{
series
.Column(model => model.deneme, categoryExpression: model => model.EvrakTarih).Name("deneme")
.Aggregate(ChartSeriesAggregate.Count);
series
.Column(model => model.digerdeneme, categoryExpression: model => model.EvrakTarih).Name("digerdeneme")
.Aggregate(ChartSeriesAggregate.Count);

series
.Column(model => model.deneme2, categoryExpression: model => model.EvrakTarih).Name("deneme2")
.Aggregate(ChartSeriesAggregate.Count);

})
.CategoryAxis(axis => axis
.Date()
.BaseUnit(ChartAxisBaseUnit.Months)


.MajorGridLines(lines => lines.Visible(true))
)
.Theme("metro")
.Tooltip(tooltip => tooltip
.Visible(true)
.Template("#= series.name #: #= value #"))
Alex Hajigeorgieva
Telerik team
 answered on 31 Oct 2019
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
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?