How to make filtering work with UniGrid when populating data in code behind?

Kentico Support Engineer asked on January 24, 2014 13:44

How to make filtering work with UniGrid when populating data in code behind?

Correct Answer

Kentico Support Engineer answered on January 24, 2014 13:44

If you are populating UniGrid data in code behind as mentioned in this KB article (devnet.kentico.com/Knowledge-Base/Web-parts-Controls/Advanced-UniGrid-example.aspx), filtering will not work.
Instead of populating like:

protected void Page_Load(object sender, EventArgs e)
{
    userGrid.DataSource = CMS.SiteProvider.UserInfoProvider.GetAllUsers();
}

Please register an event handler for userGrid.OnDataReload event in SetupControl:

userGrid.OnDataReload += userGrid_OnDataReload;

And use code similar to:

DataSet userGrid_OnDataReload(string completeWhere, string currentOrder, int currentTopN, string columns, int currentOffset, int currentPageSize, ref int totalRecords)
{
    return CMS.SiteProvider.UserInfoProvider.GetUsers(completeWhere, currentOrder, currentTopN, columns);
}
0 votesVote for this answer Unmark Correct answer

Recent Answers


Gene Spainhour answered on October 30, 2014 21:16

Excellent. So we overcome erroneous documentation with incomplete documentation. If I were writing an api that I wanted people to use, and pay for, I think I would write sample applications. These applications would illustrate how to, for example, implement filtering in a UniGrid populated from an external data set.

One question I read earlier asked, "Can you populate a UniGrid from an external database?" The answer from the so-called expert Kentico developer was "Sure! :)" But he didn't mention how to do it.

3 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.