We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Grid editmode classic

Thread ID:

Created:

Updated:

Platform:

Replies:

117773 Dec 11,2014 12:21 AM UTC Dec 11,2014 12:20 PM UTC ASP.NET MVC 1
loading
Tags: Grid
steve mangelschots
Asked On December 11, 2014 12:21 AM UTC

Hi


I've added an add, edit, delete button to my grid.

Is it possible to let the grid editmode to work like a

Url.Action so that I can go to a view just like the basic mvc.

                     



.EditSettings(edit =>


{



edit.AllowDeleting().AllowEditing().AllowAdding().EditMode(?);




})


.ToolbarSettings(toolbar =>


{


toolbar.ShowToolbar().ToolbarItems(items =>


{



items.AddTool(ToolBarItems.Add);


items.AddTool(ToolBarItems.Delete);


items.AddTool(ToolBarItems.Edit);




});


})










Ragavee U S [Syncfusion]
Replied On December 11, 2014 12:20 PM UTC

Hi Steve

 

Thanks for your interest in Syncfusion products.

 

We have analyzed your requirement and we don’t have inbuilt support to achieve your requirement. But we can achieve it using the ToolbarClick event of the grid. Please refer the below code snippet.

 

[MVC]

@(Html.EJ().Grid<object>("Editing")

        .EditSettings(edit => { edit.AllowDeleting().AllowEditing().AllowAdding().AllowEditOnDblClick(false); })

        .ToolbarSettings(toolbar => { toolbar.ShowToolbar().ToolbarItems(items =>

              {

              items.AddTool(ToolBarItems.Add);

              items.AddTool(ToolBarItems.Edit);

              items.AddTool(ToolBarItems.Delete);

              });

        })

        . . . .

        .ClientSideEvents(eve => eve.ToolbarClick("toolbarClick"))

)

 

[JavaScript]

<script type="text/javascript">   

    function toolbarClick(args) {   

//in the toolbarClick event checking the name of the icon clicked and performing actions accordingly   

        switch (args.itemName) {

            case "Edit": //if the name of the icon clicked is edit

                args.cancel = true; //cancelling the default action and overriding

                if (args.model.selectedRowIndex == -1)

                    alert("No records selected to perform edit operation");//if no record is selected warning message is thrown

                else {

                    var ord = args.model.currentViewData[args.model.selectedRowIndex].OrderID; //get the primary key value of the record selected 

//args.model.currentViewData[args.model.selectedRowIndex] is used to get the details of the selected record/row               

                    location.rel='nofollow' href = '/Home/Edit/?orderID=' + ord//pass the primary key value to the controller action

                }

                break;

            case "Add"://if the name of the icon clicked is add

                args.cancel = true; //cancelling the default action and overriding

                location.rel='nofollow' href = '/Home/Add'; //triggering the controller action Add

                break;            

        }

    }

</script>

 

[CS]

public ActionResult Edit(int orderID) //the passed parameter from the view code is obtained

        {

            var data = new NorthwindDataContext().OrdersViews.Where(e => e.OrderID == orderID).FirstOrDefault();//getting the record values corresponding to the record selected using the primary key.

            return View(data);   //pass the JSON object to perform model binding       

        }

public ActionResult Add()

        {

//code snippet for add query

            return View();

        }

 

In the above code snippet, we have cancelled the default edit and add operation on ToolbarClick event of the grid and thus have performed custom operation by using location.rel='nofollow' href. On editing, we have passed the OrderID value to the controller action and have filtered the data and thus use it in the corresponding view page.

 

Please get back to us if you need any further assistance.

 

Regards

Ragavee U S


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;