Telerik Forums
UI for ASP.NET MVC Forum
1 answer
327 views

Hi dear Telerik team.
I'm trying to use grid for showing and editing grid in UTC format.

@(Html.Kendo().Grid<TelerikGridTestApp.Models.ClientViewModel>()
          .Name("Grid")
          .Columns(columns =>
          {
              columns.Bound(p => p.ClientName).Title("Name");
              columns.Bound(p => p.ClientBirthday).Format("{d:0}").Title("Start Date").HtmlAttributes(new Dictionary<string, object> { { "class", "utc-date" } });
              columns.Command(command =>
              {
                  command.Edit();
              });
          })
          .ToolBar(toolbar => toolbar.Create())
          .Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("ClientEditor"))
          .Pageable(pager => pager.PageSizes(new[] { 10, 20, 30, 50 }))
          .Events(e => e.DataBound("onDataBound").Edit("onEdit"))
          .HtmlAttributes(new { style = "height: 550px;" })
          .Sortable()
          .Scrollable()
          .Resizable(configurator => configurator.Columns(true))
          .Filterable()
          .DataSource(dataSource => dataSource
              .Ajax()
              .Model(model => model.Id(p => p.ClientID))             
              .Create(create => create.Action("Client_Create", "Grid"))
              .Read(read => read.Action("Clients_Read", "Grid"))
              .Update(update => update.Action("Client_Update", "Grid"))
              .Sort(configurator => configurator.Add(c => c.ClientName))
          )
)


I understand that when data comes to browser, it converts to local date time of the browser. So I have to convert it back to UTC date time, and paste to the CELL of the grid.

function onDataBound() {
        $(".utc-date").each(function () {
            var text = LocalToUtc($(this).text());
            $(this).text(text);
        });       
    }

Also I do the same for popup dialog

@model TelerikGridTestApp.Models.ClientViewModel
 
@using (Html.BeginForm())
{
    @Html.ValidationSummary(true)
 
<fieldset>
    <legend>Client</legend>
    @Html.HiddenFor(model => model.ClientID)
    <div class="editor-label">
        @Html.LabelFor(model => model.ClientName, "Client Name")
        @Html.ValidationMessageFor(model => model.ClientName)
    </div>
    <div class="editor-field">
        @Html.EditorFor(model => model.ClientName)
    </div>
    <div class="editor-label">
        @Html.LabelFor(model => model.ClientBirthday, "Client Birthday")
    </div>
    <div class="editor-field">
        @Html.Kendo().DatePickerFor(model => model.ClientBirthday).HtmlAttributes(new { @class = "kendo-utc-date" })
        @Html.ValidationMessageFor(model => model.ClientBirthday)
    </div>
    @Html.HiddenFor(model => model.TimeZoneOffsetMinutes)
</fieldset>
}
 
@section Scripts {
    @Scripts.Render("~/bundles/jqueryval");
}

- I change dates using "onEdit" event.

function onEdit(e) {
       if (e.model.isNew())
           return;       
       var datePicker = $($("input.kendo-utc-date")).data("kendoDatePicker");
       var utcDate = datePicker .value();
       datePicker .value(toLocal(utcDate));
       var timeZoneOffsetControl = $("#TimeZoneOffsetMinutes");
       timeZoneOffsetControl.val(new Date().getTimezoneOffset())
       timeZoneOffsetControl.change();
   }

But when I press "Cancel" button or just close the dialog, the date converts back to local date in the grid. When I press "Update" button, it looks like any mechanism takes the updated date, converts it to UTC (according to my conversion) and shows on front end, but on back end I have correct date.
I figured out that the grid has a storage, and when I update the record, the grid updates the record in the storage and sends the updated record to the back end is separately. It makes sense if I update regular string or number. But What should I do in my case?

Viktor Tachev
Telerik team
 answered on 04 Sep 2018
3 answers
334 views

Hi,

I've just upgraded to the version 2018.2.620. I noticed that window.title no longer displays special characters correctly. For example:

In previous version, setting the title to finnish: "Viesti Phoenixist&#228;" rendered correctly "Viesti Phoenixistä". Now the translation of &#228 character does not work anymore.

Are there any solutions to this?

Thanks and regards,
Viktor

Benedikt
Top achievements
Rank 1
 answered on 03 Sep 2018
3 answers
1.0K+ views

I have a popup editor configured on a grid.  In the editor template, I have a dropdownfor with a Read action.  I need to pass the model value to the read action but it is not recognized.  Can you help?

Here is the editor template:

@model Procurement.Models.Pipe
<style>
    .k-edit-form-container {
        width: auto;
    }
</style>
<div class="panel" style="padding:5px;">
  
  
    @Html.HiddenFor(m => m.MaterialId)
    @Html.HiddenFor(m => m.PcsPartNum)
    @Html.HiddenFor(m => m.OuterDiameter, new { id="OD", name="OD"})
    <table>
        <tr><td colspan="2" align="center"><h4 class="text-info"> Pipe Details</h4></td></tr>
        <tr><td colspan="2" align="center"> <hr /></td></tr>
        <tr>
            <td width="30%">PCS Part Num</td>
            <td>@Html.TextBoxFor(m => m.PcsPartNum, new { ReadOnly = "true" })</td>
        </tr>
        <tr>
            <td>Description</td>
            <td>@Html.TextAreaFor(m => m.Description, new { ReadOnly = "true", TextMode = "MultiLine", Rows = "3", Cols = "500" })</td>
        </tr>
        <tr>
            <td>Sort Order</td>
            <td>@Html.TextBoxFor(m => m.Materials_Group.SortOrder, new { ReadOnly = "true" })</td>
        </tr>
        <tr>
            <td>Unit</td>
            <td>@Html.TextBoxFor(m => m.Materials_Group.Unit, new { ReadOnly = "true" })</td>
        </tr>
        <tr><td colspan="2"><hr /></td></tr>
        <tr>
            <td colspan="2" align="center">
                <table>
                    <tr>
                        <td class="text-info" width="30%">Client Part Num</td>
                        <td colspan="2">@Html.EditorFor(m => m.ClientPartNum)</td>
                    </tr>
                    <tr>
                        <td class="text-info">Additional Info</td>
                        <td colspan="2">@Html.TextAreaFor(m => m.AdditionalInfo, new { TextMode = "MultiLine", Rows = "3", Cols = "500" })</td>
                    </tr>
                    <tr><td colspan="2" align="center"><h5 class="text-info">Properties</h5></td></tr>
                    <tr>
                        <td class="text-info">Outer Diameter</td>
                        <td>@Html.DisplayFor(m=>m.OuterDiameter, new { style="width:100px;id:tbOD"})</td>
                        <td>@(Html.Kendo().DropDownListFor(m => m.OuterDiameter)
                            .Name("OuterDiameter")
                            .DataValueField("Text")
                            .DataTextField("Value")
                            .DataSource(ds =>
                            {
                                ds.Read(read =>
                                {
                                    read.Action("GetPipeOD", "Materials", new { od = m.OuterDiameter }); <<<<<< Here is where the model value needs to be sent >>>>>>>
                                });
                            })
                            .HtmlAttributes(new { style="width:100px"})
                            //.Events(e =>
                            //{
                            //    e.Change("onChange").Select("onSelect");
                            //})
                            )
                       </td>
                    </tr>
                    <tr>
                        <td class="text-info">Wall Thickness</td>
                        <td colspan="2"></td>
                    </tr>
                    <tr>
                        <td class="text-info">Specification</td>
                        <td></td>
                    </tr>
                    <tr>
                        <td class="text-info">Grade</td>
                        <td colspan="2"></td>
                    </tr>
                    <tr>
                        <td class="text-info">Seam Type</td>
                        <td colspan="2"></td>
                    </tr>
                    <tr>
                        <td class="text-info">Coating 1</td>
                        <td colspan="2"></td>
                    </tr>
                    <tr>
                        <td class="text-info">Coating 2</td>
                        <td colspan="2"></td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</div>

Dimitar
Telerik team
 answered on 03 Sep 2018
2 answers
388 views

Hi,

in my MVC-App I use <authentication mode="Windows" /> and <identity impersonate="true"/> inside web.config which means the current WindowsIdentity is delivered through IIS to SQL-Server. Normally I use the async/await pattern in my code and thus use ToDataSourceResultAsync(...) to get my filtered/sorted/paged results async. When doing so I run into an error. The call from App -> IIS -> SQL-Server is now under the normal "IIS APPPOOL\DefaultAppPool" account which is not a valid SQL-Server user and so the connection is refused. When using the normal ToDataSourceResult(...) call everything works perfect.

The reason for this is the usage of "Task.Factory.StartNew(...)" inside QueryableExtensions.cs. Whenever you use "Task.Factory.StartNew(...)" the impersonation is reset to the default value and is NOT using the identity used inside the MVC-App. Here is a little example (just place the code inside a normal Controller Action):

1.Debug.WriteLine("App is running as: {0}", WindowsIdentity.GetCurrent().Name);
2.await Task.Factory.StartNew(
3.    () =>
4.    Debug.WriteLine("New Task is running as: {0}", WindowsIdentity.GetCurrent().Name),
5.    CancellationToken.None,
6.    TaskCreationOptions.None,
7.    TaskScheduler.Default);

 

As a result you get:
Line 1: "App is running as: myDomain\myUser"
Line 4: "New Task is running as: IIS APPPOOL\DefaultAppPool"

At least you should warn in your documentation that this could happen or think about a better solution for implementing "ToDataSourceResultAsync(...)". In my opinion my scenario is not so seldom in the enterprise world so giving a warning should be a good idea.

Regards
Heiko

 

 

Heiko
Top achievements
Rank 1
Iron
Veteran
 answered on 31 Aug 2018
6 answers
677 views

Is there currently a way to use DropDownList that would allow a USER to delete an item?  We are creating a facility of saved searches and we'd love to be able to allow the user to be able to click an 'X' in a dropdown to trigger a delete of the item from the list (and ultimately the database) as seen in the attached screen shot.

 

 

Dimitar
Telerik team
 answered on 31 Aug 2018
1 answer
179 views

We are using Telerik Rad-editor (Version: 2017.2.503.40) in our application. The Rad-editor control which we use looks like the sample you provided in "Save in database" link.
We are facing 1 issue while uploading image through Image Manager control. If we upload an image then we face 1 console error. Below is the description for the error.
ScriptResource.axd?d=WumqVucm-BTOpradDSIl6FwWq2Nf8yJ7sqq9-igzn7fhpcm7LMUuXAF__xzJt_PP7G8atwaBX_21lH9wtho_Q-JsnyL97IPmZiErbgIsKQvtmeYlHiL_GqtD3HsMVT9KS6u1-fBfjgRuY07t3m9OjNcjVdzCqYRpX7UHxymyD6WPAuy90&t=ffffffffad4b7194:5 Uncaught Error: Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 500
Can you please provide us the solution/your suggestions please?

Thanks in advance.

Rumen
Telerik team
 answered on 31 Aug 2018
3 answers
2.2K+ views

Hello.

I have a dropdownlist for Contact Name in a kendo grid as shown in the attachment.

When I click on the Manage Contacts button, I get a pop up which has a grid where I insert contacts.

After inserting/updating contacts and closing the popup, the Contact Name dropdownlist should display the new contacts which have just been inserted when I click on Edit for that particular row.

But this not happening. 

The code for the Contact Name editor template is as follows:

@(Html.Kendo().DropDownList()
.Name("ContactName")
.ValuePrimitive(true)
.DataValueField("ContactName")
.DataTextField("ContactName")
.OptionLabel(" ")
.DataSource(source =>
{
    source.Read(read =>
    {
        read.Action("GetVendorContacts", "VendorCont")
        .Data("filterContactName");
    })
    .ServerFiltering(true);
})
    //.AutoBind(false)
    .CascadeFrom("Vendor")
)

Is there a way to refresh the dropdown list when I click on the Edit button on the row or when I click on the dropdown list to select contacts?

I have tried to refresh the dropdownlist using the BeforeEdit and Save events, but it did not work.

This is very urgent and any help will be greatly appreciated.

 

Thanks and Regards

 

Veselin Tsvetanov
Telerik team
 answered on 30 Aug 2018
2 answers
809 views

Hi,

I have a detail template in a grid. In the last column I want to have a dropdown menu based on a condition. In another (regular) grid I did this:

columns.Template(@<text></text>).ClientTemplate(@"<div class='dropdown'>
                                                            <a data-toggle='dropdown' class='primarycolor' href=''><i class='fa fa-ellipsis-v fa-2x'></i></a>
                                                            <ul class='dropdown-menu dm-icon pull-right'>"
+ "# if (ShowEditLink) { # <li><a class='k-button-icontext editReg' href='#=EditLink#' data-rid='#=Id#'>" + translator.Translate("EDIT_REGISTRATION") + "</a></li> # } #"
+ "</ul></div>").HtmlAttributes(new { @class = "dropdown-gridcell" }).Width(20);

 

Now I know that in the child/detail context I have to escape template expression with "\\#=fieldName\\#. Found here: https://demos.telerik.com/aspnet-mvc/grid/detailtemplate

What I'm trying is this:

columns.Template(@<text></text>).ClientTemplate(@"<div class='dropdown'>" +
  "<a data-toggle='dropdown' class='primarycolor' href=''><i class='fa fa-ellipsis-v fa-2x'></i></a>" +
  "<ul class='dropdown-menu dm-icon pull-right'>" +
"# if (booleanProperty) { # <li><a class='k-button-icontext' href='' data-spid='#=Id#'>" + translator.Translate("CANCEL") + "</a></li> # } #" +
"</ul></div>").HtmlAttributes(new  {  @class = "dropdown-gridcell"  }).Width(20);

where "booleanProperty" is a property of the viewModel in the child grid. This doesn't work because it doesn't recognize "booleanProperty" since it thinks it is in the viewModel of the parent grid. I have looked at the following posts:

https://www.telerik.com/forums/nested-detail-grid-clienttemplate-conditional-binding-expression-error

https://docs.telerik.com/aspnet-mvc/helpers/grid/faq#how-to-display-checkboxes-in-ajax-bound-grids

 

and tried this as well:

columns.Template(@<text></text>).ClientTemplate("\\#=showLink(booleanPropoerty, Id)\\#").Title("").HtmlAttributes(new  {  @class = "dropdown-gridcell"  }).Width(20);

function showLink(booleanProperty, id) {

var returnValue = "<div class='dropdown'><a data-toggle='dropdown' class='primarycolor' href=''><i class='fa fa-ellipsis-v fa-2x'></i></a><ul class='dropdown-menu dm-icon pull-right'>";

if (booleanProperty) {
return "<li><a class='k-button-icontext' href='' data-spid='" + id + "'>" + $('#stringValue').val() + "</a></li>";
}

returnValue += "</li></div>";

return returnValue;
}

This way I get returned a value but the required javascript for the dropdown list doesn't work.

 

Is there a solution for this?

 

Thank you,

Jokull

Jokull
Top achievements
Rank 1
 answered on 30 Aug 2018
1 answer
268 views

Grid data source is as follow:

public class Customer

{

    public string customer_id { get; set; } = "";

    public string customer_name { get; set; } = "";

    public List<Order> Orders { get; set; } = "";

    public List<Delivery> Delivery{ get; set; } = "";

}

public class Order

{

    public string order_id { get; set; } = "";

}

 

public class Delivery
{
    public string delivery_id { get; set; } = "";
}

 

My design:

Master grid will present Customer record(List<Customer>), and when I click edit button, it will pop up a edit template

and edit template will include Customer's data and two sub grids(Order, Delivery). 

 

My question is I know if I want to get string, it would be "#=customer_id#" but I don't know if I want to get List -- Order and Delivery -- to bind sub grids data source, how can I do.

Does anyone help me?

Viktor Tachev
Telerik team
 answered on 30 Aug 2018
3 answers
411 views
Hello.
I have a dropdownlist for Contact Name in a kendo grid as shown in the attachment.
When I click on the Manage Contacts button, I get a pop up which has a grid where I insert contacts.
After inserting/updating contacts and closing the popup, the Contact Name dropdownlist should display the new contacts which have just been inserted when I click on Edit for that particular row.
But this not happening. 
The code for the Contact Name editor template is as follows:
@(Html.Kendo().DropDownList()
.Name("ContactName")
.ValuePrimitive(true)
.DataValueField("ContactName")
.DataTextField("ContactName")
.OptionLabel(" ")
.DataSource(source =>
{
    source.Read(read =>
    {
        read.Action("GetVendorContacts", "VendorCont")
        .Data("filterContactName");
    })
    .ServerFiltering(true);
})
    //.AutoBind(false)
    .CascadeFrom("Vendor")
)
Is there a way to refresh the dropdown list when I click on the Edit button on the row or when I click on the dropdown list to select contacts?
I have tried to refresh the dropdownlist using the BeforeEdit and Save events, but it did not work.
This is very urgent and any help will be greatly appreciated.

Thanks and Regards
Georgi
Telerik team
 answered on 30 Aug 2018
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?