Telerik Forums
UI for ASP.NET MVC Forum
2 answers
344 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
605 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
154 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
700 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
234 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
350 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
3 answers
854 views

Hi, I realized the 2 bar chart in a single mvc5/bootstrap page as shown in the image "actual.jpg" (see the code) I would like to obtain the result in "wanted.jpg" in short an overlapping bar chart and changing categories colors, there is a way to do this?

Thank You in advance.

code:
<div class="container-fluid">
    <div class="row">
        <div class="col-xs-18 col-md-12">
            @(Html.Kendo().Chart()
                                    .Name("chart-multi")
                                    .Title("First")
                                    .Legend(legend => legend
                                        .Position(ChartLegendPosition.Top)
                                    )
                                    .Series(series =>
                                    {
                                        series
                                            .Column(new int[] { 20, 40, 45, 30, 50 })
                                            .Color("#cc6e38")
                                            .Spacing(-1)
                                            .Name("on battery");
                                        series
                                            .Column(new int[] { 20, 30, 35, 35, 40 })
                                            .Color("#ef955f")
                                            .Name("on gas");
                                    })
                                    .CategoryAxis(axis => axis
                                        .Categories("Mon", "Tue", "Wed", "Thu", "Fri")
                                        .AxisCrossingValue(0, 10)
                                    )
                                    .ValueAxis(axis => axis
                                        .Numeric()
                                            .Title("miles")
                                            .Min(0).Max(100)
                                    )
                                    .ValueAxis(axis => axis
                                        .Numeric("km")
                                            .Title("km")
                                            .Min(0).Max(161).MajorUnit(32)
                                    )
            )
        </div>
    </div>
</div>

<div class="container-fluid">
    <div class="row">
        <div class="col-xs-18 col-md-12">
            @(Html.Kendo().Chart()
                                        .Name("bar-chart")
                                        .Title("Second")
                                        .Series(series =>
                                        {
                                            series.RangeColumn(new double[][] {
                                                               new double[] {0, 121.99},
                                                               new double[] {38.47, 121.99},
                                                               new double[] {16.17, 38.47},
                                                               new double[] {0, 16.17}
                                            }).Labels(labels => labels
                                                .Visible(true)
                                                .From(from => from.Template("#=value.from#"))
                                                .To(to => to.Template("#=value.to#")));
                                        })
                                        .CategoryAxis(axis => axis
                                            .Categories("Total", "Done", "Committed", "Uncommitted")
                                        )
                                        .Tooltip(tooltip => tooltip
                                            .Visible(true)
                                            .Template("#= value.to - value.from #")
                                        )
            )
        </div>
    </div>
</div>

Alex Hajigeorgieva
Telerik team
 answered on 29 Aug 2018
1 answer
1.2K+ views

Hi All,

I want to display an icon in the kendo grid at the last with click event functionality ,Kindly provide me a sample .Please find the attached screen shot how it should be.

In the grid display my code is displayed below

  columns.Bound(p => p.CampaignName).Title("Campaign Name").Width(120).HtmlAttributes(new { @class= "text-left" });
  columns.Bound(p => p.CampaignType).Title("Channel Type").Width(100).HtmlAttributes(new { @class = "text-left" });
  columns.Bound(p => p.LeadType).Title("Lead Type").Width(60).HtmlAttributes(new { @class = "text-left" });

  ///Here display images/icons code///

Kindly help me to achieve the above scenario

Thanks & Regards,

Sampath

Preslav
Telerik team
 answered on 28 Aug 2018
1 answer
446 views

I am using the grid with pop up editing. When a record is being created or updated we perform some validation logic to make sure a record with the same name value is not already present. If one if found we do not create or update the record and need to alert the user of this. I've looked for this but everything I've found deals with if an error has occurred and in this case no error occurs but the code simply does not continue.

public ActionResult Classification_Create([DataSourceRequest] DataSourceRequest request, Classification classification)
        {
            if (classification != null && ModelState.IsValid)
            {
                this.Create(classification);
            }
            return Json(new[] { classification }.ToDataSourceResult(request, ModelState));
        }
 
 private void Create(Classification classification)
        {
            try
            {
                // Check for duplicate before adding
                var classificationCheck = _db.Classifications.FirstOrDefault(x => x.Name == classification.Name && x.DivisionId == classification.DivisionId);
 
                if (classificationCheck == null)
                {
                    classification.Active = true;
                    _db.Classifications.Add(classification);
                    _db.SaveChanges();
 
                    // Log the creation
                    Logging.CreateLog("Classification", classification.Id, "New classification record created", PlatformSession.CurrApplications[PlatformApplicationSession.OperationHighlights]);
                }
                else
                {
                    // Check to see if it's just makred as inactive and return a message to user
                    string errorMessage = !classificationCheck.Active ? "A classification with this name already exists but is simply in-active. Please locate this classification and re-activate it." : "A classification with this name already exists for this division. Please check the data again and re-try.";
                    ViewBag.Error = errorMessage;
                }
            }
            catch (Exception ex)
            {
                // Log the error
                ExceptionHandling.CreateErrorLog(ex, PlatformSession.CurrApplications[PlatformApplicationSession.OperationHighlights]);
                // Send the user to a notification screen.
                string errorMessage = "There was an issue creating the routing template and this has been logged. Please try again but if this persists please contact a platform administrator.";
                ViewBag.Error = errorMessage;
            }
        }

 

In the Create method we perform a simply check to see if this record exists. If so we do not create the record and place a message into a ViewBag object. In the current layout the pop-up window goes away and nothing has been added. I would like to have the window stay in place and another window appear that contains the message the server placed into the ViewBag object.

 

 

Viktor Tachev
Telerik team
 answered on 28 Aug 2018
Narrow your results
Selected tags
Tags
Grid
General Discussions
Scheduler
DropDownList
Chart
Editor
TreeView
DatePicker
Upload
ComboBox
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
ListView (Mobile)
Pager
Accessibility
ColorPicker
DateRangePicker
Wizard
Security
Styling
Chat
MediaPlayer
TileLayout
DateInput
Drawer
SplitView
Barcode
ButtonGroup (Mobile)
Drawer (Mobile)
ImageEditor
RadioGroup
Sparkline
Stepper
TabStrip (Mobile)
GridLayout
Template
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
+? more
Top users last month
Edmond
Top achievements
Rank 1
Iron
fabrizio
Top achievements
Rank 2
Iron
Veteran
RobMarz
Top achievements
Rank 2
Iron
Fakhrul
Top achievements
Rank 1
Iron
Tejas
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Edmond
Top achievements
Rank 1
Iron
fabrizio
Top achievements
Rank 2
Iron
Veteran
RobMarz
Top achievements
Rank 2
Iron
Fakhrul
Top achievements
Rank 1
Iron
Tejas
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?