Posts

Showing posts with the label MVC

How to use Checkbox in Kendo UI open source Grid

You can easily put a checkbox in Kendo UI Grid. Just define its template while defining the columns  See the code below... scrollable: true,                         sortable: true,                         filterable: true,                         columns: [                             {                                 field: "FirstName",                                 title: "Location (City Country)",                                 width: 100       ...

How to Pass a Model in MVC Jquery AJAX call?

I got this simple solution from stackoverflow and it worked for me. Model: public class AddressInfo { public string Address1 { get ; set ; } public string Address2 { get ; set ; } public string City { get ; set ; } public string State { get ; set ; } public string ZipCode { get ; set ; } public string Country { get ; set ; } } Controller: public class HomeController : Controller { public ActionResult Index () { return View (); } [ HttpPost ] public ActionResult Check ( AddressInfo addressInfo ) { return Json ( new { success = true }); } } script in View: < script type = "text/javascript" > var ai = { Address1 : "423 Judy Road" , Address2 : "1001" , City : "New York" , State : "NY" , ZipCode : "10301" , Country : "USA...

How to set "Search" button as default on Enter using Javascript

How To set Default Button  for ENTER key pressed event? Or Setting enter key   default button  when login control and  search   ? You can submit a form when you enter something in a search field and press Enter (Return) button on keyboard using javascript code. < input type ="text" name ="searchFor" onkeydown ="if(event.which || event.keyCode)                                                      {if ((event.which == 13) || (event.keyCode == 13))                                                      {document.getElementById('your search button ID').click/>

Hide some of the field in telerik MVC Grid PopUp edit or any other Edit Mode

Hi there... Hide any field in telerik mvc grid edit mode. Here is a general idea, may be some error in code as it works perfect for my project but may be different for others. 1. Add a client side event in your grid .ClientEvents(events => events                             .OnEdit("onEdit")                             ) 2. Write the onEdit event in javascript It finds the column name, then you can hide the column by css property. function onEdit(e) {       $(e.form).find("#myModelPropertyName").closest(".editor-field").prev().andSelf().remove();     } Thanks.

How to change the date format in Telerik mvc grid inline edit mode

Image
Telerik mvc grid inline edit mode” finally I got a solution by which we can change the date format while using Telerik mvc grid inline edit mode. Here is the simple code. 1.  Just add a client side event to your grid .ClientEvents(events => events                             .OnEdit( "onEdit" )                             ) 2.  Add this event in your javacript code function onEdit(e) {         var dataItem = e.dataItem;         var sDate = new Date(dumpDate(dataItem));         if (isNaN(sDate.getMonth())) {             ...

Telerik mvc grid datepicker not showing up the grid date in the Inline Edit mode

Image
Hi, it seems the most common problem in telerik grid inline edit mode that the datepicker is empty or the date format changes while you edit a row. I have tried with various tricks by changing the format in  Views\Shared\EditorTemplates\DateTime.cstml , sometimes it works but sometimes we need some customer format to show the user while picking up the date. For example we are showing the date in this format 19/July/2012 but we want to show the user in this format while he pick a new date to change 19/07/2012 So let me explain how we can customize date time format in Telerik mvc grid inline edit mode. I guess you have no need to touch Views\Shared\EditorTemplates\DateTime.cstml for this purpose. 1.   Add a client event in your grid .ClientEvents(events => events                             .OnRowDataBound( "on...

How to add a custom button in Telerik MVC Grid Column with Edit and delete Button

Image
Telerik MVC Razor Code : columns.Command(commands => { commands.Edit().ButtonType( GridButtonType .Image);                                      commands.Custom( "myButtonName" ).ButtonType( GridButtonType .Image).Action( "myAction" , "myController" ).Ajax( true ); commands.Delete().ButtonType( GridButtonType .Image); }); Javascript Code : You can also assign a custom style to the button by using client side event onRowDataBound. Here is the code. function onRowDataBound(e) { var del = $(e.row).find($( '.t-icon.t-ProcessPayment' ));         del.css( 'background-image' , 'url("/Content/Images/SettingsBG.png")' );         del.css( 'background-repeat' , 'no-repeat;' );         del.css( 'background-position-x' , 0);       ...

How to add a custom button in Telerik MVC Grid Toolbar like “Add New Record” Button

Image
.ToolBar(commands =>  {  commands.Insert().ButtonType( GridButtonType .Text);    commands.Custom().Name( "mybtn" ).Text( "This Is Title" ).ButtonType( GridButtonType .Text).Action( "myAction" , "myController" ).Ajax( true ); })

How to pass a model from view to controller using javascript in MVC 3

JS Code: Funtion PassModel(){ var UserModel = {                 UserName: ‘Test’,                 PhoneNo: ‘00000000000’,                 Address: ‘ABCDEFGHI…’ }; var URL = "/UserController/UserAction?userdetails=" + UserModel;                     $.get(URL, function (data) {                         ShowResult(data.SaveResult);                     }); } HTML Code ( View ): < input name ="ClickedButton" type ="button" id ="b...

How to make simple AJAX call on HTML input button and get JSon result in MVC 3

Here is the simplest code to make Ajax calls to MCV on an HTML button click using javascript. JS Code: funtion  btnClick(){ var URL = "/myController/ myAction ?userID=" + Parameter1 + "&ReceiptNo=" + Parameter2 ;                     $.get(URL, function (data) {                         ShowResult(data.ProcessResult);                          } HTML Code ( View ):   <input name="ClickedButton" type="button" id="btnclickme" value="Check Result"                     onclick="btnClick()" class="commonbtn FR" /> C# Code ( Controller ): public ActionResult myAction(string  Parameter1 ,string  Parameter2   ) {     int  ProcessResult  = 1;     return Json(new { ProcessResult }, JsonReque...