Display Dialog box through Datagrid in QPanel
Hi,
I am trying to display one of my page through the dialog box in QPanel. The code for the same is at: http://pastebin.com/m5bb316b9. The highlihted code (lines 238 to 242) try to display the CoTSItemListPanel2. It gives me following error:
qc.getWrapper("c47") is undefined on line number 214 in file http://localhost/projectco/assets/js/_core/post.js
and after that an AJAX error popup with lot of junk characters.
Notice the page here is called through a normal button.
The interesting part is that if I try to call the same page through another datagrid on QPanel with MetaAddEditProxyColumn it displays well on dialog box.
Please suggest what I need to do.
Thank you.

Did you by any chance forget to do a Render() call in your .tpl file on the dialog box? The symptoms resemble what I've seen in the past for that error.
I didn't. As I said if I call the same thing from a column that is created through metacontrol, it works.
OK. There's quite a bit of code to look through here, I simply can't dive deeply enough to understand all the details because of time constraints, but I'll try to help.
Can you talk a little bit about why you're using $this->dtgCoTSHeader as a parent for the dialog box, as opposed to just the form? Is $this->dtgCoTSHeader initialized at the time when you're constructing the dialog box? Can you construct the dialog box earlier, and initially hide it, and in your function on line 232, just display it?
I tried bot the things:
1. Using $this instead of $this->dtgCoTSHeader.
2. Declaring it at the top and hide it and then show it at 232
Nothing really helps.
Thanks.
Can you create an isolated sample .zip that demonstrates the issue, so that I can reproduce it and test?
It seems to me, that you haven't included dialog box render into template (as Alex referred).
With dialog box, you have to render it as dialog box. If you just create dialog box after the click, it isn't rendered in template as dialog box (as template will be rendered before you initialize the dialog box). In the case of rendering dialog box in column, the dialog box will be created with template creation, eg everything will work fine.
The problem is, that javascript, which will be run in showdialogbox, wants that there exists a control with given ID on the page. If it isn't rendered (as it probably is the case with your onclick event), it gives you an error.
Those are just my thoughts. I have had some headache regarding those dialogboxes. As I probably mentioned in some post, I usually create an empty hidden dialog box at the beginning of my form. Later on, if I need something to show in dialog box, I just change the content of the dialog box and show it. Otherwise (if you change the whole dialog box), you might have similar troubles you currently have and if you change some control entirely, the whole parent control's HTML will be reloaded (eg, if you have dialog box in your form, basically everything will be reloaded, which is big nono for performance).
Alex,
I am sorry, without db I won't be able to create the example. Could you be able to help if I upload all the files in zip?
Meanwhile, I have uploaded the remaining files too:
1. CoTSHeaderListPanel2.tpl.php: http://pastebin.com/m4bfe0a8e
2. CoTSItemListPanel2.class.php: http://pastebin.com/me3b7805
3. CoTSItemListPanel2.tpl.php: http://pastebin.com/m11449f69
Agsel,
As you will find in the CoTSItemListPanel2.tpl.php I have included the code for rendering the datagrid that is inside my dialog box. You are correct it is very frustrating, I am trying to do this for last 2 weeks. I initially thought I will be able to manage it without you guys help.
One more thing if I replace the code for calling the dialog box in CoTSHeaderListPanel2.class.php (http://pastebin.com/m5bb316b9) by the calculator widget in the example code, it also gives the same error. But if I do the same thong onto another page that is developed through metagrid, it works.
Please help.
CoTSItemListPanel12.tpl.php
Change:
<?php$_CONTROL->$dtgCoTSItem->Render();
?>
to:
<?php$_CONTROL->dtgCoTSItem->Render();
?>
Try that and post any errors.
Basilieus,
Changed, now the same error is coming after I press the button 2nd time. First time nothing happens...
Give me a dump of your error, thanks.
Here it is: http://pastebin.com/m6cd2c105
Thanks.
lol what the hell is that?
that is what I get after that pop up...
You still have the same problem.
If you create dialog box, you only define datagrid as its parent. But nowhere in datagrid will it be rendered. So, your dialog box simply won't be rendered in HTML and js will give you an error. Although I think that this error should make more sense.
What you need to do:
1) whether render your dlgCoTSItemPane in some cell of datagrid (eg SomeColumn_Render)
2) or render it in your template.
If you choose 1), you have to make sure, that dlg will get rendered only once. Let me know, how it goes.