You must Sign In to post a response.
  • Category: ASP.Net MVC

    Sorting in partial view Grid, without post back

    I am calling below partial view from a Main view - .

    View2.cshtml-
    -------------
    @Html.Grid(Model.TVModel).Named("ResultsGrid").Columns(c =>
    {
    c.Add(mod => mod.Log.SiteID).Titled("Site ID").SetWidth(100);
    c.Add(mod => mod.Log.ProcessDateFrom).Titled("Date Processed").SetWidth(100)
    c.Add(mod => mod.Log.ProcessDateTo).Titled("Date Processed").SetWidth(100).Sortable(true) // setting grid sorting

    How to implement sorting on above partial view. On click of column header, the column should get sorted without post back
  • #768675
    Hi,

    Hope you are not using any 3rd tool for this DataGrid. Because all the DataGrid from 3rd party have this functionality by default. We have many free tool for datagrids and it related operations.

    Below are the free .NET libraries from third party datagrid which are dynamic

    http://www.dreamincode.net/forums/topic/224164-free-3rd-party-datagrid/

    http://www.xtremevbtalk.com/-net-general/317248-3rd-party-datagrid-view-control.html

    http://qink.net/page/The-Ultimate-List-of-Freely-Available-_NET-Libraries.aspx

    Thanks,
    Mani

  • #768695
    You can try this code snippet as example for Sorting in partial view Grid
     ALTER PROC[dbo].[CC_GetStudentList]  
    @PageNumber INT,
    @PageSize INT,
    @SortExp VARCHAR(20)
    AS
    BEGIN;
    WITH CteStudent
    AS(SELECT ROW_NUMBER() OVER(ORDER BY CASE WHEN @SortExp = 'EXAM_Asc'
    THEN EXAM END ASC, CASE WHEN @SortExp = 'EXAM_Desc'
    THEN EXAM END DESC, CASE WHEN @SortExp = 'Tests_Asc'
    THEN TestRuns END DESC, CASE WHEN @SortExp = ''
    THEN ID END ASC)[RowNo], * FROM dbo.StudentProfile(NOLOCK))
    SELECT CteStudent.RowNo,
    CteStudent.ID,
    CteStudent.Name,
    CteStudent.EXAM,
    CteStudent.Tests,
    CteStudent.EXAMRuns,
    CteStudent.TestRuns, (SELECT COUNT(CteStudent.ID) FROM CteStudent) AS TotalCount
    FROM CteStudent
    ORDER BY CteStudent.RowNo
    OFFSET(@PageNumber - 1) * @PageSize ROWS
    FETCH NEXT @PageSize ROWS ONLY;
    END;


Sign In to post your comments