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 : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Selecting a row on load of Syncfusion grid

Thread ID:

Created:

Updated:

Platform:

Replies:

107168 Feb 18,2013 06:52 AM UTC Feb 28,2013 03:58 AM UTC ASP.NET MVC (Classic) 3
loading
Tags: Grid
Sivakumar
Asked On February 18, 2013 06:52 AM UTC

Hi,

I am working on ASP .NET MVC4. In my view, left side partial view contains Syncfusion grid to display data and  on selecting any record in grid rendering partial views on right side. This is working fine upto now. If I pass SelectionId to View, I have to select a row and render partial views on load of grid.

Could you please help me on this?

This is very urgent for me. 

Thanks in advance.

Regards,
Siva

Bala Murugan A.S [Syncfusion]
Replied On February 19, 2013 11:22 AM UTC

Hi SivaKumar,

Thanks for using Syncfusion Products.

We suggest you to use _selectRow property in OnLoad client side events to select row while on loading grid. Please refer the below code snippet.

[Grid1.cshtml]

.ClientSideEvents(events=>events.OnLoad("OnLoadGrid1"))

[JavaScript]

<script type="text/javascript">
    function OnLoadGrid1(sender, args) {
        sender._selectRow=2; // 2 - row index
    }
</script>

Please try the above code snippet and let us know if you have any concerns.

Regards,
Bala Murugan A.S

Sivakumar
Replied On February 19, 2013 01:57 PM UTC

Hi Bala Murugan,

Thanks for the solution. But I do not know the row index to set on load of grid. I am just having SelectionId(Primary key of the Custom list, which is bind to grid). So using this Id how can I select a row on load of the grid?

Please help me on this?

Regards,
Sivakumar

Bala Murugan A.S [Syncfusion]
Replied On February 28, 2013 03:58 AM UTC

Hi Sivakumar,

Thanks for your update.

We suggest you to pass row index which you want to select from controller to view through response header and select row based on the row index in using _selectRow attribute. Please refer the below code snippets.

[Code snippet]

public ActionResult Index(PagingParams par)

        {

            if (par.GridID == "Grid1")

            {

                var data1 = Employee.GetList();

                ViewData["GridData1"] = data1;

                //Get the index of the record which you want to select

                Response.AddHeader("RowIndex", data1.Select((obj, index) => new { obj.EmployeeID, Index = index }).SingleOrDefault(x => x.EmployeeID == 3).Index.ToString());

                return data1.GridJSONActions<Employee>();

            }

            else if (par.GridID == "Grid2")

            {

                var data1 = Employee.GetList();

                ViewData["GridData2"] = data1;

                //Get the index of the record which you want to select

                //Response.AddHeader("RowIndex", data1.Select((obj, index) => new { obj.EmployeeID, Index = index }).SingleOrDefault(x => x.EmployeeID == 3).Index.ToString());

                return data1.GridJSONActions<Employee>();

            }

            return View();

        }

 

[script]

<script type="text/javascript">

    $('#Grid1').ajaxSuccess(function (evt, request, settings) {

        var Index = request.getResponseHeader('RowIndex'); //get your data from response header

        if (Index != null) {

            var gridObj = $find('Grid1');

            gridObj._selectRow=Index;

 

        }

    });

</script>

Please let us know if you have any concerns.

Regards,

Bala Murugan A.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

;