Module UIgrid Edit functionality

Mani SJ asked on March 1, 2020 23:31

I have UIgrid which shows a list of objects. When I inspect the Edit button functionality in browser I can see below

onclick="return window.CMS.UG_m_c_plc_lt_ctl01_Listing_gridElem.redir('\/MyProjectName\/CMSModules\/AdminControls\/Pages\/UIPage.aspx?elementguid=31d7cbfe-1c46-4471-beca-499226b1a7ac&displaytitle=false&objectid=1');__doPostBack('m$c$plc$lt$ctl01$Listing$gridElem$v$ctl02$aedit','')"

elementguid is the guid of the element under module. This won't change for the object list in UIgrid but objectid differs for every element in UIgrid. So when I click edit button corresponding object is opened in edit mode based on objectid.

I want to implement this functionality in code behind. I have a button in another .aspx page. When I click the button right now I am going to module page(object list) but I want to go to a edited object page based on a id(provided from button click).

I constructed the URL based on below

ApplicationUrlHelper.GetElementUrl("ModuleName", "ElementName", false, Objectid); *ElementName GUID is the one showing in elementguid

When I copy the generated URL and paste in browser. I am just getting the UI of ElementName without Kentico Navbar and without back arrow(back to module page)within the UI.

Not sure how to do the redirect like window.CMS.UG_m_c_plc_lt_ctl01_Listing_gridElem.redir()

Recent Answers


Brenden Kehren answered on March 2, 2020 06:17

Have you reviewed the documentation on how to create a module which includes the UI part of editing the records?

This documentation tells you how to create the UI pieces for adding and editing records from the listing.

0 votesVote for this answer Mark as a Correct answer

Mani SJ answered on March 2, 2020 06:29

I read those before while creating module but not helpful for my current situation. So far I stored generated application URL in a Session Variable and using this session variable in my UIgrid control extender OnInit() method

If session not null I am doing below

page.ClientScript.RegisterClientScriptBlock(this.GetType(), "JavaScript", "<script>" +
"window.CMS.UG_m_c_plc_lt_ctl01_Listing_gridElem.redir('\\/MyProjectName\\/CMSModules\\/AdminControls\\/Pages\\/UIPage.aspx?elementguid=31d7cbfe-1c46-4471-beca-499226b1a7ac&amp;displaytitle=false&amp;objectid=1');__doPostBack('m$c$plc$lt$ctl01$Listing$gridElem$v$ctl02$aedit','')</script>");

but it keeps throwing below error

Uncaught TypeError: Cannot read property 'UG_m_c_plc_lt_ctl01_Listing_gridElem' of undefined
0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on March 2, 2020 06:37

They are very helpful. You can create the whole UI part of the module simply by adding a single XML file which defines the grid (no need to create your own in code). Then configure the rest of the module which will automatically create the URLs you're looking for automatically.

Look in this documentation again and review the XML file which defines the UniGrid. If you feel the need to write a bunch of code, your probably doing it wrong. You can write extensions and custom web parts vs create a bunch of custom module pages.

0 votesVote for this answer Mark as a Correct answer

Mani SJ answered on March 2, 2020 06:46

Hi Brenden, I am not sure you understood my question fully. I referred Kentico documentation on how to create module. I am aware of XML file for UniGrid, Extenders for UniGrid control.

My problem is I have a button in a separate .aspx page. When I click that button I want to open a object in the Unigrid list in edited mode(like the page you land after manually clicking the edit icon in Unigrid).

I am able to go to my module page upon button click(link text) right now I am extending further on this

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on March 2, 2020 06:53

Depending on where you are at in the UI, I would highly recommend against sending them to that page. I'd create a page within the page you have created to bring that object up and edit it right there vs the module UI. Much easier to manage, maintain. Check out the BasicForm to perform your edit operations with

0 votesVote for this answer Mark as a Correct answer

Mani SJ answered on March 2, 2020 06:59 (last edited on March 2, 2020 07:00)

Unfortunately I have few vertical tabs when the object enters edit mode in my custom module, So I want to replicate redirect in my .aspx button to be the redirect as kentico does for edit icon. Each vertical tabs are like steps in a process.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on March 2, 2020 07:03

I'd suggest looking at some other module controls code to see how they generate those URLs in code behind. There may be no documentation on that but I know there is code for it in the /CMSModules directory.

0 votesVote for this answer Mark as a Correct answer

Mani SJ answered on March 3, 2020 00:29

If you are aware of any file under /CMSModules directory kindly let me know as I am still searching but no luck so far

0 votesVote for this answer Mark as a Correct answer

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