Why Ext.getCmp is a bad practice? Can be replaced with itemId in all scenarios? - extjs4

I´ve been using ExtJS for a while and always used "Ext.getCmp" when instanciating components, but most of the time I read that it´s a bad practice and that "itemId" should be used instead, so I´d like to know why is "itemId" better than "Ext.getCmp" and if can be used always.
Additionally I´ve encounter examples where i´m not able (or don´t know how) to use "itemId".
Example:
I can set the disabled property of a button with "Ext.getCmp":
Ext.getCmp('btnMyButton').setDisabled(true);
But with "itemId" I get error: "object reference not set to an instance of an object"
btnMyButton.setDisabled(true);

You have to get button element by item id then call the setDisabled.
Ext.ComponentQuery.query('#btnMyButton').setDisabled(true);
You can refer below link to understand more on id vs itemId
https://vimeo.com/14816550

Related

Getting reference from model One2many relationship comodel inside an ir.actions.act_window

Would like to ask on how you can get the id of the comodel inside the ir.actions.act_window.
See my source code: https://gist.github.com/renesansz/2642b02875475383605e
Currently, I cannot get the sprint_id.project_id.current_sprint reference since it's giving me an error of Uncaught Error: NameError: name 'sprint_id' is not defined. So what I wanted to happen is that upon opening the project it should add a default filter for the current sprint of the project.
Do I have any alternative for this kind of approach?
Tried doing domain, but still no luck solving the issue.
Try this: make related field and then use this field in xml view.

How to fix TypeError: transform(...) is null

Another individual said this error is generally caused by "a widget template that is referencing a property via ${...} that doesn't actually exist in the widget."
I've researched and can't seem to find a way to resolve this error. Any advice or leads to help solve this issue? How do you FIND this bit of code to correct the issue?
Got some assistance from SitePen.
Here's the trace Stack -
**string.substitute/<()string.js (line 147) string.substitute()string.js
(line 141) ._updatePaginationStatus()Pagination.js (line 395)
.gotoPage/
return transform(value, key).toString();
instrum...tion.js (line 20)**
The Pagination was failing - potentially trying to pull data before it was actually there.
"Code is trying to do a string.substitute call, but the transformation you're trying to do isn't valid. It looks like the Pagination extension is failing on this. Given the number of steps related to Deferreds, it looks like something is trying to parse data before that data is available. For example, you have an async call, but are treating the data synchronously.
That said, when using the Pagination extension, I think you use the normal Grid rather than the OnDemandGrid."
I switched from OnDemandGrid to Grid - left pagination. Error still there. Switched back to OnDemandGrid - eliminated Pagination. Error Gone.
Also found this little note that I had overlooked in documentation: "Note that the Pagination extension is incompatible with OnDemandGrid, since each has its own way of dealing with collection ranges. Pagination should be mixed into Grid, not OnDemandGrid."
http://dgrid.io/tutorials/0.4/grids_and_stores/
thankyousitepen

Which way is it better to call ORM methods in Odoo 7?

Let's say you have in your code an object of model 'account.invoice' and inside a method you want to update the partner. I noticed that you have two ways of calling the 'write' method on model 'res.partner'. You could either do :
invoice.partner_id.write({'name': 'Mister Test'})
OR
partner_obj = self.pool.get('res.partner')
partner_obj.write(cr, uid, invoice.partner_id.id, {'name': 'Mister Test'})
I always used the second way because it is the one that is always described in documentations. However, I discovered that the first way is also working and is shorter. Is it ok to do so ?
When object is browse record than I direct write browse record object.write({'field_name': value})
invoice.partner_id.write({'name': 'Mister Test'})
This line give error because partner_id is a many2one field so it's store integer number. So you can’t use this.
For this you must to browse that partner_id and than you may to write on partner object.
And second point, if you want write something in invoice object than you can use this for example invoice.write({'field_name': value}) this will work.
Hope this make a sense.

Grails trouble saving object id

id is present in the params but does not save to the db. for example
[book.id:1, comments: good]
comments will save to db but book.id does not.
I need to figure out how to save params.book.id into the db column BOOK_ID that was created from the hasmany/belongsTo relationship.
By default value attribute of each element will be the result of a toString() call on each element. Setting it as optionKey allows the value to be a bean property of each element in the list.
Kindly change the select to
<g:form action="review">
<g:select name="book.id"
from="${item.Book.list()}"
value="${book?.id}"
/>
<g:textField name="bookreview" value="${params?.bookreview}" /><br>
kindly refer the below link
Grail example with optionkey
You have overwritten toString, therefore your books are always rendered by name and not id. If you remove your toString() method you will see the expected results.
If you want your select box work with the name, just add optionValue="name".
Well, it seems that I had misspelled a crucial parameter inside my domain. So the domain was expecting x and it was getting y. Thus the id was always null. It took me a while to spot it, and I was perplexed because I had previously successfully implemented ids in another project. Grails has some jira issues also that make one consider other possibilities, but this time it was my mistake.

Displaying Custom Attributes in Documentum - Webtop

I am following an article that explains how to use the ICustomAttributeDataHandler class.
I am creating a custom column for the inbox screen, but the problem is that the value I set for my custom attribute is not being reflected on the screen.
As a test I am changing the task name to "whoKnows". But this code is not effecting what is output on the screen:
ICustomAttributeRecordSet.setCustomAttributeValue(i, "taskName", "whoKnows");
(I am able to print debug lines from my custom class when the inbox is viewed, so I know my code is being run.)
Someone on the comments of that article wrote:
the user must call the
"setCustomAttributesInQuery() method
on the dataprovider passing in a
string array of the custom attributes
...what does that meen? Could this be my problem?
thanks.
To be honest, I have already used Webtop, but just as an user. I found a post in the dm developer discussion group that can be useful, though:
For creating a custom column in the
doclist you dont need to go through
this complex procedures. You can use
custom attribute datahandlers for
this.
First in your object list component xml file add your custom column
definition in the "columns" tag. You
can even add static columns instead of
the documentum attributes.
Now create a class which implements the ICustomAttributeDataHandler.
Implement the default the methods getRequiredAttributes and the getData
function.
In getRequiredAttributes add attributes of the object that you are
looking for.
In your getdata method retrieve each row and then based on the
attribute that you see, just set the
value that you want to. 6) Finally
define your class in the app.xml file
There is a section in WDK developement
guide regarding
ICustomAttribuetDataHandlers. Look for
the topic named "Adding custom
attributes to a datagrid".
I'm not sure if this is the final solution, but I hope it helps!
To answer you question about setCustomAttributesInQuery()
every datagrid in WDK is backed by an underlying data provider. You can get this proivder by using the following code.
Datagrid datagrid = (Datagrid)getControl("doclist_grid",com.documentum.web.form.control.databound.Datagrid.class);
DataProvider dp = datagrid.getDataProvider();
Once you've done that, you can call
dp.setCustomAttributesInQuery(myArr);
I'm not actually sure if this is part of the solution to your problem, but you could try this and see where it gets you.
You have to configure the inbox component.
if using classic view, go to inboxlist component and add your custom attribute.
<column>
<attribute>CustomAttributeName</attribute>
<label>Custom Attribute Label</label>
<visible>true</visible>
</column>
Your custom attribute has to be in a custom type that is a sub type of dmi_queue_item, because inboxlist shows only dmi_queue_item objects.
Hope this helps,
Regards,
Tejas.
This may be a non-issue, but based on your code, I can't tell if you're doing this:
ICustomAttributeRecordSet.setCustomAttributeValue(i, "taskName", "whoKnows");
or this:
ICustomAttributeRecordSet rs;
rs.setCustomAttributeValue(i, "taskName", "whoKnows");
You should be calling the setCustomAttributeValue method on the rs object instance, not on the interface.