Menu
  • HOME
  • TAGS

Select a row and pass id to another element on the page using KendoGrid

Tag: asp.net-mvc-4,kendo-grid,kendo-ui-mvc

I am in ASP.NET MVC environment and I am creating a page with two parts.

  1. Grid which shows all the employee data
  2. When a user clicks on a particular row in the grid, it shows the employee related data in the part below

I have used the Selectable() attribute on the Grid. However some of the things are not very clear to me that

  1. If it raises any event when I do that?
  2. If not, how to I read the value of a particular row OR any particular column while doing it?

Best How To :

If you want to catch event click, you can use

 $("body").on("dblclick", "#grid tbody tr", function (e) {
  var grid= $("#grid").data('kendoGrid');
  var rowSelect = grid.select();
  var dataSelect = grid.dataItem(rowSelect);
 });

KendoUI Grid - Complex JSON with inconsistent keys

javascript,json,kendo-ui,kendo-grid

You can use column templates: columns: [ { field: "id", title: "User Id" }, { field: "name", title: "User Name", }, { field: "type", title: "User Type", template: function(dataItem) { return dataItem.type ? kendo.htmlEncode(dataItem.type) : ""; } }, { field: "address", title: "Street 1", template: function(dataItem) { return dataItem.address.street1 ?...

Form Post Not working While Submission

c#,asp.net,asp.net-mvc,asp.net-mvc-4

You have to fix your connection. But incorrect connection string may have different causes. Try to connect to your database with Server Explorer in Visual Studio then select your database and press F4 (Properties). You can see the correct connection string there. Put it in connection string in your web.config.

Dynamically adding controls in MVC4

asp.net-mvc,asp.net-mvc-4

You can create a editor template and pass the control list as model to the template and in the template you can iterate that list to generate the control. As i have shown below. 1->Create a class for Control Information. public class ControlInfo { public string ControlType { get; set;...

MVC 5 OWIN login with claims and AntiforgeryToken. Do I miss a ClaimsIdentity provider?

asp.net-mvc,asp.net-mvc-4,razor,asp.net-mvc-5,claims-based-identity

Your claim identity does not have ClaimTypes.NameIdentifier, you should add more into claim array: var claims = new List<Claim> { new Claim(ClaimTypes.Name, "Brock"), new Claim(ClaimTypes.Email, "[email protected]"), new Claim(ClaimTypes.NameIdentifier, "userId"), //should be userid }; To map the information to Claim for more corrective: ClaimTypes.Name => map to username ClaimTypes.NameIdentifier => map...

Why is my View not displaying value of ViewBag?

c#,asp.net,asp.net-mvc,asp.net-mvc-4,razor

ViewBag is used when returning a view, not when redirecting to another action. Basically it doesn't persist across separate requests. Try using TempData instead: TempData["Tag"] = post.SelectedTag.ToString(); and in the view: <p><strong>Tag: @TempData["Tag"]</strong></p> ...

A specified Include path is not valid. The EntityType '*Propiedad' does not declare a navigation property with the name 'Nombre'

c#,asp.net-mvc,entity-framework,asp.net-mvc-4,repository-pattern

Include is made to eagerly load navigation properties, meaning any property that is, in fact, another related entity. Since Nombre is a string, you do not need to include it: it is part of the entity that is returned from the database call. If Nombre were of a class representing...

Prevent page refresh on submit button click

asp.net-mvc-4

In the server-side validation ,the page must be submitted via a postback to be validated on the server and if the model data is not valid then the server sends a response back to the client. With client-side validation, the input data is checked as soon as they are submitted,...

Unable to make parent li active on click of child li with bootstrap in mvc4

c#,asp.net,asp.net-mvc-4,c#-4.0

There are 2 things to do, one is make the active selection when user clicks and the other is save this selection after the page refreshs right? If you want to make li selected after the page refresh you need to save this state somewhere. You can save it in...

How to hide columns in Kendo Grid when editing in a popup

asp.net-mvc,kendo-ui,kendo-grid,kendo-asp.net-mvc

You can use the edit event of the grid to hide some element from the popup window: $("#grid").kendoGrid({ edit: function(e) { e.container.find(".k-edit-label:first").hide(); e.container.find(".k-edit-field:first").hide(); } }); ...

Set default attribute for all Kendo UI Grids

javascript,kendo-ui,kendo-grid

This is an all or nothing change, but will do just that. Set the default options for the scrollable to false kendo.ui.Grid.fn.options.scrollable = false; You will want to set that before any kendo grids are created....

Display value of a textbox inside another textbox using AngularJs on button click

angularjs,asp.net-mvc-4

in your controller do , $scope.myFunction = function () { $scope.display = $scope.type; } in your html you have to change onclick to ng-click, <input type="button" value="button" ng-click="myFunction()" /> see this plunk for example, http://plnkr.co/edit/c5Ho1jlixwZFx7pLFm9D?p=preview...

How to Implement Dependent Dropdownlist in MVC4 Razor and using SQL server also

sql-server,asp.net-mvc-4,razor

Note : As per your requirement you need to show country name when user selects the state then why you need dropdownlist for country ?? it is better to use a label for that. For you requirement first you have to maintain a table which stores country and it's state...

Kendo Grid Date is null for 13/06/2015 all dates after 12

asp.net-mvc,razor,kendo-grid,kendo-asp.net-mvc

This appears to be a culture issue. Try changing your Kendo UI culture (by including one of the other culture JS files. You may also need to change the culture on the server

Angularjs ng-show doesn't work with Viewbag

angularjs,asp.net-mvc-4

Try this: <div ng-show="'@(ViewBag.AllowExport)'"> <a href="JavaScript:void(0);">Export</a> </div> ...

Add XElement dynamically using loop in MVC 4?

c#,xml,asp.net-mvc-4,for-loop

This is the complete code [HttpPost] public ActionResult SURV_Answer_Submit(List<AnswerQuestionViewModel> viewmodel, int Survey_ID, string Language) { if (ModelState.IsValid) { var query = from r in db.SURV_Question_Ext_Model.ToList() join s in db.SURV_Question_Model on r.Qext_Question_ID equals s.Question_ID where s.Question_Survey_ID == Survey_ID && r.Qext_Language == Language orderby s.Question_Position ascending select new { r, s };...

Need to Close the div in if condition MVC View

asp.net-mvc,asp.net-mvc-4

I think you need something like this, run two loops one for total and one for two items. so this condition of loose close elements will not occur. @for (int count = 0; count <= ViewBag.modal.Count; count++) { <div class="Class1"> @for (int counter = 0; counter < 2 && (count...

Conflicted with the REFERENCE constraint. How to solve this?

asp.net-mvc-4,nhibernate

Judging by that error, your repository is trying to delete the a user from its table but that user is referenced in another table (dbo.Invoices). So you are seeing a foreign key constraint error where you are trying to delete a record who's primary key is referenced in another table...

MVC 4 - pass parameter to controller on button click

asp.net-mvc-4

The input buttons have a value. You can detect the value of the input button at the controller. <input type="submit" value="submitbutton"> <input type="submit" value="savebutton"> ...

How to store a string in xml file and use it in _Layout in MVC

c#,xml,asp.net-mvc,asp.net-mvc-4

Sourced: from this link The web.config (or app.config) is a great place to store custom strings: in web.config: <appSettings> <add key="message" value="Hello, World!" /> </appSettings> in cs: string str = ConfigurationSettings.AppSettings["message"].toString(); ...

How to add validators for @Html.TextBox() without model

asp.net-mvc,asp.net-mvc-4

Add data-val and data-val-required attribute for Html.TextBox() as shown below. <script src="~/Scripts/jquery-1.10.2.min.js"></script> <script src="~/Scripts/jquery.validate.min.js"></script> <script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script> @using (Html.BeginForm("","")) { @Html.ValidationSummary() @Html.TextBox("bill_address", null, new { @class = "form-control valid", @data_val = "true", @data_val_required = "Billing Address is required" }) <input type="submit" value="Click"...

Binding my view model to a view causes all check boxes to be checked

c#,asp.net,asp.net-mvc,asp.net-mvc-4,razor

In your view, remove <input type="checkbox" value="" checked="checked"/> Allow Access Because of checked="checked", this will always print out a checked checkbox....

Custom Data Annotation and MVC Helper

c#,asp.net-mvc,asp.net-mvc-4

You're gonna need to extend the HtmlHelper class with the following: public static MvcHtmlString HelpTextFor<TModel, TValue>(this HtmlHelper<TModel> helper, Expression<Func<TModel, TValue>> expr) { var memberExpr = expr.Body as MemberExpression; if (memberExpr != null) { var helpAttr = memberExpr.Member.GetCustomAttributes(false).OfType<HelpTextAttribute>().SingleOrDefault(); if (helpAttr != null) return new MvcHtmlString(@"<span class=""help"">" + helpAttr.Text + "</span>"); }...

C# entity framework MVC second run error

entity-framework,asp.net-mvc-4,localdb

Your initialiser is using the DropCreateDatabaseAlways class which, as it suggests, drops that database every time the application is initialised. Instead perhaps you could use CreateDatabaseIfNotExists or DropCreateDatabaseIfModelChanges: public class ComponentDbInitialize : CreateDatabaseIfNotExists<ComputerContext> { } ...

Use Bearer Token Authentication for API and OpenId authentication for MVC on the same application project

c#,asp.net-mvc-4,oauth-2.0,openid,identityserver3

Ok, I found some information on the following post https://github.com/IdentityServer/IdentityServer3/issues/487 The github repo that implements the concepts discussed in the link can be found here https://github.com/B3nCr/IdentityServer-Sample/blob/master/B3nCr.Communication/Startup.cs Basically you need to map the api url to a different configuration using app.Map(). In my case, I changed my startup file to look...

check for value null on razor syntax

c#,asp.net-mvc,asp.net-mvc-3,asp.net-mvc-4,razor

try this: @{ if (propiedadesFormularioDetalle != null) { <div class="panel panel-default"> <div class="panel-heading">Propiedades adicionales</div> <div class="panel-body"> <dl class="dl-horizontal"> foreach (KeyValuePair<string, string> propiedad in propiedadesFormularioDetalle) { <dt> Html.DisplayName(propiedad.Key) </dt> <dd> Html.DisplayFor(prop => propiedad.Value) </dd> } </dl> </div> } </div> } ...

How do I reference a specific cell in kendo grid with javascript?

javascript,kendo-ui,kendo-grid,kendo-asp.net-mvc

In kendoGrid each data is represented by array of objects in which one array element is one row. Kendo adds uid property to all dataObjects in array. So one dataObject looks like: var dataItem = { MetricName: "some-val", DailyActual: "some-val", DailyTarget: "some-val", MTDActual: "some-val", MTDTarget: "some-val", YTDActual: "some-val", YTDTarget: "some-val",...

Mvc Remote Attribute is sending “undefined” in query string

c#,asp.net,asp.net-mvc,asp.net-mvc-4

You need to add @Html.HiddenFor(m=>m.UserId) at the view so that the binder will bind it to the remote validation controller or otherwise there is no value to bind ...

Using Bootstrap 3 DateTimePicker in ASP.NET MVC Project

jquery,asp.net-mvc,twitter-bootstrap,asp.net-mvc-4,bootstrap-datetimepicker

The easiest way in MVC with bootstrap would be to set the properties in your model with DataAnnotations. Here is a link that should help you. Using Data Annotations for Model Validation [DisplayName("Owners Date of Birth:")] Will display in the @Html.LabelFor and this will be the label for your field....

MVC Push notification from server to client side

asp.net-mvc-4,push-notification

You can use SignalR : $.connection.hub.start().done(function () { $('#sendmessage').click(function () { // Call the Send method on the hub. chat.server.send($('#displayname').val(), $('#message').val()); // Clear text box and reset focus for next comment. $('#message').val('').focus(); }); }); use more info: tutorial...

How to get started with Visual studio 2012

c#,asp.net-mvc,asp.net-mvc-3,asp.net-mvc-4,visual-studio-2012

Download this book "Microsoft ASP.NET 4 Step By Step" by George Shepherd.I found it very helpful.It will address all the issues you raised here.Thank you.

Why mozilla changes the characters when i use the .net mvc statement redirect?

c#,asp.net-mvc-4,redirect,mozilla

%E2%80%8B is a URL-encoded, UTF-8 encoded ZERO-WIDTH SPACE character. You likely have one hiding in your application setting file for the ProActiveOffice-URL value. It was maybe pasted in that way, if you copied the URL from somewhere.

ASP .Net MVC get decorated roles for unathorized request

c#,asp.net,asp.net-mvc,asp.net-mvc-4

The AuthorizeAttribute has a property called Roles that you should be able to check to get the information you want. As mentioned by @EricFunkenbusch you can assume that the user is not in any of those roles. https://msdn.microsoft.com/en-us/library/dd460323(v=vs.118).aspx...

C# Using Bool, how to check a double is truly divisible by another number? [duplicate]

c#,asp.net-mvc-4

You can use the %-operator: bool isDivisible = 1115 % 100 == 0; The % operator computes the remainder after dividing its first operand by its second. All numeric types have predefined remainder operators. ...

How do you send data to controller with ajax.beginform?

ajax,asp.net-mvc-4,razor,model-view-controller,model

To make you understand how AJAX FORM works, I created below code - Lets say our model - public class Sale { public string SaleOwner { get; set; } public virtual Account Account { get; set; } } public class Account { public string Name { get; set; } }...

How to programically collapse or expand Kendo Grid Group by values in row

jquery,asp.net-mvc,kendo-ui,kendo-grid

The first level of the dataSource is the groups. Then each group has a property called items which is actually the rows in the group. So try this: var grid = $("#grid").data("kendoGrid"); var dataView = grid.dataSource.view(); for (var i = 0; i < dataView.length; i++) { for ( var j...

Rendering “~/bundles/jqueryval”

c#,asp.net-mvc,asp.net-mvc-4,razor

You need to declare the section within your "master page": @RenderSection("Scripts", false) Probably the best idea to include this in the head tag. Otherwise it doesn't know what to do with your Scripts section defined in your child view. The second parameter, which I've set to false is whether or...

Exact need of jquery.validate.js

jquery,asp.net-mvc-4,jquery-validate

jQuery Validate is just an addon for jQuery you could use. So you still got to write the validation yourself, even though jQuery Validate makes a lot of things easier. Here is a documentation on the plugin you should check out, to use it for your needs....

C# mvc4 - direct URL to controller

c#,asp.net-mvc-4,url,redirect

You might have forgotten to specify name of the controller in Html.ActionLink() parameter. Try Html.ActionLink("actionname","controllername");

Format DateTime.ParseInfo

c#,datetime,kendo-grid

With ParseExact(): using System.Globalization; var value = "Mon Jun 15 2015 00:00:00 GMT+0200 (Central Europe Daylight Time)"; var trimedValue = value.Substring(0, value.IndexOf(" (")); var dateTime = DateTime.ParseExact(trimedValue, "ddd MMM dd yyyy HH:mm:ss 'GMT'zzz", CultureInfo.InvariantCulture); ...

mvc 4 custom format validator does not show error and allows the form to submit

asp.net-mvc,validation,asp.net-mvc-4

In order to get client side validation, your attribute must implement IClientValidatable and you must include a client side script that adds a method to the client side $.validator object. This article THE COMPLETE GUIDE TO VALIDATION IN ASP.NET MVC 3 gives some good examples of how to implement it....

Setting up routing when RemoteAttribute specifies AdditionalFields

c#,asp.net,asp.net-mvc,asp.net-mvc-4

When it receives a query such as /Validation/IsUserNameAvailable?userName=BOB&UserID=, MVC's model binder is confused because it does not know how to handle null/empty string params. Just change the param to an int and cast as necessary for your helper method: public JsonResult IsUserNameAvailable(string userName, int UserId) { var users = new...

startIndex cannot be larger than length of string

c#,entity-framework,asp.net-mvc-4

You should have code in following way - string newFilenameExtension = Path.GetExtension("Sample".Trim()); string extn = string.Empty; if (!String.IsNullOrWhiteSpace(newFilenameExtension)) { extn = newFilenameExtension.Substring(1); } if(!String.IsNullOrWhiteSpace(extn)) { // Use extn here } ...

404 when converting asp.net mvc app to angularjs

c#,asp.net,asp.net-mvc,angularjs,asp.net-mvc-4

MVC pattern means the controller takes requests and renders views. You are trying to bypass that and the Views/web.config prevents that. You can either render your view via the Controller (MVC-style), or configure a section of your app to serve static files ...

Partial View's checkbox state not returned to controller

c#,asp.net,asp.net-mvc,asp.net-mvc-4,razor

asp.net MVC model binding can only bind to one model. To solve your issue you would simply need to create a base class that all your models, that may use a FacilityList , would derive from. Like so: public class FacilityViewModel { public Dictionary<string, bool> FacilityList { get; set; }...

Why does my MVC binding stop working when I assign a nested model to a variable?

c#,asp.net-mvc,asp.net-mvc-4,razor

If you inspect the html you are generating you will see that they are not the same. Your first code block generates html like <input name="NestedModel[0].Id" id="NestedModel_0__Id" .../> <input name="NestedModel[1].Id" id="NestedModel_1__Id" .../> The second one will generate html like <input name="nestedModel.Id" id="nestedModel_Id" .../> <input name="nestedModel.Id" id="nestedModel_Id" .../> The second generates...

Implementing KendoUI grid search with dataSource filtering

javascript,html,kendo-ui,kendo-grid

To enable the bound value to update the filter change it to: viewModel.get('searchValue') Full code: $("#grid").data("kendoGrid").dataSource.filter({ logic: 'or', filters: [ { field: 'lastName', operator: 'startswith' }, { logic: 'or', filters: [ { field: 'lastName', operator: 'startswith', value: viewModel.get('searchValue') }, { field: 'address', operator: 'startswith', value: viewModel.get('searchValue') } ] } ]...

Getting Kendo Grid from its DataSource

kendo-ui,kendo-grid

There is no API to get Grid object from data source, but there is many approach beside that. You can create generic grid's edit event and storing in global scope variable which grid's ID was triggered that event. I prefer to do this rather than compare mutable data source. var...

Cannot get data using LINQ in MVC

c#,asp.net-mvc,linq,asp.net-mvc-4

Ensure term matches the case of the data. As all the data is loaded (.ToList() in the DAL), the .Where clause uses .Net comparison rather than SQL comparison: var vehicle = _service.GetAll().Where(c => c.Name.StartsWith(term, StringComparison.OrdinalIgnoreCase)... If, in the future, you want to change this to Contains, you can add an...

How to get data out of ember objects

javascript,ember.js,kendo-grid

You could use getProperties method. http://emberjs.com/api/classes/Ember.Object.html#method_getProperties To get the values of multiple properties at once, call getProperties with a list of strings or an array: record.getProperties('firstName', 'lastName', 'zipCode'); // { firstName: 'John', lastName: 'Doe', zipCode: '10011' } You could define computed property dataArray: dataArray: function() { return this.get('data').map( function(item) {...

Use “Contains” to match part of string in lambda expression

c#,jquery,asp.net-mvc-4,lambda

I would search your initial items (before you made the into a list of TextValuePair) then you could do something like IEnumerable<Item> items = originalItemsList; switch (source) { case "1": // or whatever this should be items = items.Where(x => x.ItemNumber.IndexOf(data, StringComparison.InvariantCultureIgnoreCase) > -1); break; case "2": // or whatever...