How to add server controls into Kentico unigrid ?

Ali Shahrokhi asked on November 9, 2015 03:19

I have looked up everywhere in Kentico 8 documentations and I couldn't find any information regarding add server or html controls within unigrid.

I need to add a simple check box or a drop down list in one of the unigrid column but I can't find any ways to do that! the only thing that I found was GridOptions.ShowSelection which is a general selection for selecting each row that I don't need.

any help would be greatly appreciated.

Recent Answers

Maarten van den Hooven answered on November 9, 2015 10:03

You can jump into the event OnExternalDataBound in the Unigrid codebehind see for example

An create here dynamic a new web part or a user control.

For example:

In your XML you have this column

<column source="##ALL##" externalsourcename="yourcolumn" caption="" wrap="false" />

Then in your codebehind of the UniGrid

protected object UniGrid_OnExternalDataBound(object sender, string sourceName, object parameter)
    ContextResolver resolver = CMSContext.CurrentResolver.CreateContextChild();
    DataRowView drv;

    switch (sourceName.ToLower())
        case "yourcolumn":
            drv = (DataRowView)parameter;
            CheckBox chk = new CheckBox();
            chk.ID = "chkDoc";
            chk.CssClass = "normalcheckbox";
            chk.InputAttributes.Add("Value", ValidationHelper.GetString(drv["NodeGUID"], string.Empty));
            return chk;
2 votesVote for this answer Mark as a Correct answer

Ali Shahrokhi answered on November 9, 2015 23:42 (last edited on November 9, 2015 23:43)

Excellent! Thanks buddy. but what is that ContextResolver resolver = CMSContext.CurrentResolver.CreateContextChild(); for ?

what is the equivalent of resolver in version 8 ?

0 votesVote for this answer Mark as a Correct answer

Maarten van den Hooven answered on November 11, 2015 08:29

Hi Ali, Sorry ContextResolver resolver = CMSContext.CurrentResolver.CreateContextChild(); is not necessary in your situation, I used it my old Kentico 7 code for resolving macros, but that is handled differently in Kentico 8+.

0 votesVote for this answer Mark as a Correct answer
