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.
Unfortunately, activation email could not send to your email. Please try again.

Current Page and Current Selected Row

Thread ID:

Created:

Updated:

Platform:

Replies:

123680 Apr 10,2016 03:46 PM Apr 11,2016 06:53 AM ASP.NET MVC 1
loading
Tags: Grid
Brent Nelson
Asked On April 10, 2016 03:46 PM

Is there an easy way to pass the current page and current row via a hyperlink to another page?  For example, I have a grid with an edit link in the last column.  I'd love to be able to send the user back to the exact page as they left when they went off to edit the record.  See code example below.

Thanks,
Brent


    Html.EJ().Grid<Litify.Web.Data.Pub>("Grid")
                .Datasource((IEnumerable<Litify.Web.Data.Pub>)Model)
                .AllowSorting()
                .AllowPaging()
                .PageSettings(p => { p.PageSize(20); p.EnableQueryString(true); })
                .AllowGrouping()
                .AllowFiltering()
                .FilterSettings(filter => { filter.FilterType(FilterType.Excel); })
                .AllowTextWrap()
                .AllowResizing()
                ///.EnablePersistence(true)
                .Columns(col =>
                {
                    col.Field(p => p.PubId).HeaderText("Id").IsPrimaryKey(true).Width(10).Add();
                    col.Field(p => p.Category).HeaderText("Category").Width(15).Add();
                    col.Field(p => p.FirstAuthor).HeaderText("First").Width(15).Add();
                    col.Field(p => p.Year).HeaderText("Year").Width(10).Add();
                    col.Field(p => p.Title).HeaderText("Title").Width(80).Add();
                    col.HeaderText("Actions").Width(10).Template("<a rel='nofollow' href='Pubs/DetailsEdit/{{:PubId}}?page={{:page}}'>Edit</a>").Add();
                })
                .Render();
}

Seeni Sakthi Kumar Seeni Raj [Syncfusion]
Replied On April 11, 2016 06:53 AM

Hi Brent,

To pass a current page of Grid and the selected row via QueryString to another page, you can use the TemplateRefresh event. In the TemplateRefresh event, you can append the a query string to the rel='nofollow' href attribute as shown in the below code example and refer to the TemplateRefresh event Help Document.

@(Html.EJ().Grid<EmployeeView>("HierarchyGrid")

        .Datasource((IEnumerable<object>)ViewBag.datasource)

            . . . ..

        .Columns(col =>

        {

            col.Field("EmployeeID").HeaderText("Employee ID").Width(75).Add();

               . .  . . ..  .

            col.HeaderText("Actions").Width(20).Template("<a rel='nofollow' href='/Home/Contact'>Edit</a>").Add();

        })

        .ClientSideEvents(events=>events.TemplateRefresh("templateRefresh"))

)


<script>

    function templateRefresh(args) {

        var rel='nofollow' href = $(args.cell).find("a").attr("rel='nofollow' href");

        $(args.cell).find("a").attr("rel='nofollow' href", rel='nofollow' href + "?Page=" + this.model.pageSettings.currentPage + "&SelectedRow=" + args.rowIndex);

        //this.getRowByIndex(args.rowIndex); to get a row based on index

        //this.model.currentViewData[args.rowIndex]; to get the current data based on the index

    }
</script>


http://help.syncfusion.com/js/api/ejgrid#events:templaterefresh

We have also prepared a sample that can be downloaded from the following location.

Sample: http://www.syncfusion.com/downloads/support/forum/123680/ze/Grid_TempCol-1383763116.zip

You have quoted that would like to get back to Grid page with its state retained after performing editing action. To persist state of Grid page and other model properties, you can use enablePersistence property of Grid. While switching to Grid page after editing, the Grid will show the page where customer left. Refer to the following Help Document.

http://help.syncfusion.com/js/api/ejgrid#members:enablepersistence

Regards,
Seeni Sakthi Kumar 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.

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.

;