Thursday, 29 August 2013

How to add serial number column in kendo ui grid

Using MVC
  

@(Html.Kendo().Grid<MvcApplication1.Models.TestModels>()
    .Name("Grid")
    .Columns(columns =>
    {
        columns.Bound(p => p.ID);
        columns.Bound(p => p.Name);
        columns.Template(t => { }).Title("Row No").ClientTemplate(
            "#= renderNumber(data) #"
        );
        columns.Template(t => { }).Title("Record No").ClientTemplate(
            "#= renderRecordNumber(data) #"
        );

    })
    .Pageable(x => x.PageSizes(new int[] { 10, 20, 30, 50 }).Refresh(true))
    .Sortable()
    .Filterable()
    .DataSource(dataSource => dataSource
        .Ajax()
            .Read(read => read.Action("Grid_Read", "Home"))

    )
        .Events(ev => ev.DataBound("resetRowNumber"))
)
Using Javascript
  

Wednesday, 14 August 2013

.net interview question

Question 1:
  
public class Person
{
    public string Name { get; set; }
}
public class Program
{
    private static void Main(string[] args)
    {
        var person1 = new Person { Name = "Test" };
        Console.WriteLine(person1.Name);//Output:Test

        Person person2 = person1;
        person2.Name = "Shahrooz";
        Console.WriteLine(person1.Name);//Output:Shahrooz

        person2 = null;
        Console.WriteLine(person1.Name);//Output:???
    }
}
For answer this please check below link. Click here to see Answer


Question 2:
  
public class MyClass
{
    public void Func(Object a)
    {
        Console.WriteLine("Object");
    }

    public void Func(String a)
    {
        Console.WriteLine("String");
    }
}
public class Program
{
    private static void Main(string[] args)
    {
        MyClass mc = new MyClass();
        mc.Func(null);
    }
}
For answer this please check below link.
Click here to see Answer
Click here to see Answer

Tuesday, 18 June 2013

Multi Selection Combobox in Kendo UI

  

Selected values :
  

If in your page combobox is used more then once then please check below code snippet:
  

Selected values :
  



LIVE DEMO

Friday, 24 May 2013

How to add multiple lines series dynamically in kendo UI chart

JavaScript
  

HTML
............. .............
Annully Monthly Weekly Daily
Below code snippet is only for reference to create Dummy data in MVC.

Controller
  
public class HomeController : Controller
{
    [AllowAnonymous]
    [HttpGet]
    public JsonResult GetDummydata(int Duration)
    {
        List>TestModels> models = GetDummyData(Duration);

        return Json(models, JsonRequestBehavior.AllowGet);
    }

    public List<TestModels> GetDummyData(int Duration)
    {
        List<TestModels> models = new List<TestModels>();

        switch (Duration)
        {
            case (int)DurationType.Annully:

                TestModels testModel = new TestModels();
                testModel.Field1 = "Annully";
                testModel.Field2 = 20;
                testModel.Field3 = 50;
                testModel.Field4 = 70;
                models.Add(testModel);

                break;
            case (int)DurationType.Monthly:

                TestModels testModel2 = new TestModels();
                testModel2.Field1 = "Monthly";
                testModel2.Field2 = 50;
                testModel2.Field3 = 50;
                testModel2.Field4 = 50;
                models.Add(testModel2);

                break;
            case (int)DurationType.Weekly:
                TestModels testModel3 = new TestModels();
                testModel3.Field1 = "Weekly";
                testModel3.Field2 = 70;
                testModel3.Field3 = 10;
                testModel3.Field4 = 90;
                models.Add(testModel3);
                break;
            case (int)DurationType.Daily:
                TestModels testModel4 = new TestModels();
                testModel4.Field1 = "Daily";
                testModel4.Field2 = 11;
                testModel4.Field3 = 111;
                testModel4.Field4 = 1111;
                models.Add(testModel4);
                break;

        }

        return models;
    }
}
Model
  
 [Serializable]
    public class TestModels
    {   
        public string Field1 { get; set; }
        public int Field2 { get; set; }
        public int Field3 { get; set; }
        public int Field4 { get; set; }
    }


DOWNLOAD DEMO

Saturday, 4 May 2013

How to add a new worksheet after all of the others in Excel Interop

Worksheet xlNewSheet = null;

// Add new worksheet in workbook
xlNewSheet = (Excel.Worksheet)xlWorkbook.Worksheets.Add(missing, missing, missing, missing);

// Add new worksheet at the end of all sheets in workbook
xlNewSheet = (Excel.Worksheet)xlWorkbook.Sheets.Add(After: xlWorkbook.Sheets[xlWorkbook.Sheets.Count], Count: 1, Type: Excel.XlSheetType.xlWorksheet);

// Give worksheet name
xlNewSheet.Name = worksheetName;