How to add sub-properties to property group in CMFCPropertyGridProperty - mfc

How do I add properties dynamically to CMFCPropertyGridProperty? I know we have a method AddProperty to add properties but I want to add my new property as a sub-item to a property already added to CMFCPropertyGridProperty. I can use GetProperty method to get any property using index. But I am not able to add my new property as a sub-item to the property which I have retrieved.

I got it worked.
CMFCPropertyGridProperty* pGroup = m_wndPropList.GetProperty(Index);
CMFCPropertyGridProperty *prop = new CMFCPropertyGridProperty(_T(“SampleName”), (_variant_t) _T(“SampleValue”), _T("Custom Property"));
pGroup->AddSubItem(prop);
m_wndPropList.AdjustLayout(); // This redraws the properties

Related

Replacing Field values in Word Document QAxObject QT / C++

I'm really new to QT and I was tasked to update some field values in word document programmatically, currently I can replace text from word document fine, but when that field value is inside an object (table or anything) it's not working, my code is:
QString outFile("D:\\#test files\\output.docx");
QString inFile1("D:\\#test files\\input.docx");
QAxObject axObject("Word.Application");
QAxObject* documents = axObject.querySubObject("Documents");
QAxObject* document = documents->querySubObject("Open(const QString&, bool)", inFile1, true);
QAxObject* selection = axObject.querySubObject("Selection");
auto find = selection->querySubObject("Find");
QString sOld = "${name}";
QString sNew = "Ibrahim";
bool bMatchCase = false;
bool bMatchWholeWord = false;
bool bMatchWildCards = false;
bool bReplaceAll = true;
QVariantList vl = { sOld, bMatchCase, bMatchWholeWord, bMatchWildCards, false, false, true, 1, false, sNew, bReplaceAll ? "2" : "1" };
find->dynamicCall("Execute(QString,bool,bool,bool,bool,bool,bool,int,bool,QString,int)", vl);
document->dynamicCall("SaveAs(const QString&)", outFile);
document->dynamicCall("Close()");
axObject.dynamicCall("Quit()");
If you can help it would be awesome :)
If you can change the nature of the target files, you would do well replacing your targets with real Word DocVariable or DocProperty fields. Then use your code to change the variable or properties and update the related fields in the documents. Some document properties (under the Quick Parts > Document Properties menu) are mapped to XML data points and do not require updating of fields if those are used.
The placeholder can be (1) a DocVariable field or (2) a DocProperty field. You can change the variables or properties using code and then update the field.
You can also use one of the built-in mapped Document Property Content Controls in which case there is no need to update a field if the property is changed. It is automatic. More on these in my related page: Repeating Data Mapped Document Property Content Controls or Other Mapped Content Controls.
Here are links to two Word MVP pages on accessing Document Properties using vba.
How Can I Get Access to the Document Properties of a Document Without Opening the Document
How to Use a Single vba Procedure to Read or Write Both Built-In and Custom Document Properties

set List filters in ExtJS grid dynamically from response

I am trying to set(check) List filters of a grid column dynamically
from response.
I am able to set them but when I open the menu of the corresponding
filter and setting some other combination of data to filter
dynamically it is getting selected and later cleared.
Is the code am using below for setting filters is right?Need help.
var gridFilter = currentGrid.columns[i].filter;
gridFilter.setActive(true);
gridFilter.filter.value="SELECTED,REJECTED"; //putting static data for now
gridFilter.filter.setValue(["SELECTED", "REJECTED"]);
Best way to add and Edit filter for ExtJs is FilterBy method:
grid.getStore().filterBy(function(rec, id)) {
return (rec.get("DynamicRecName")=="DynamicFilterRecord");
}
If you want to edit existing then just remove current filters:
grid.getStore().clearFilters()

get the recently added item from sitecore

If I create an item in sitecore from code behind using following code as shown in example under the heading Creating items:
//Now we can add the new item as a child to the parent
parentItem.Add("NewItemName", template);
And then in order to get the this newly added item from sitecore database what I should do? Because I don't know the ID.
The new item will be returned by the add method.
Eg.
Item newItem = parentItem.Add("NewItemName", template);

Sitecore: multilist during deployment

How to enable the multilist to be control in content editor?
for example I have a list of item, item1 to item10. In the standard template value, I defined item1,2,3. After I have deploy the solution, how am I going to enable users in content editor mode or page editor mode to select item7,8,9 and 10?
And also, after I tested/rendered the multilist, only RAW VALUES are being rendered, is there any possible to render the item name such as item1? Do I need to customize the multilist?
The multilist control should be directly visible to the user in the Content Editor, you do not need to do anything else. Since you defined some items in standard values then those will be "pre-selected" when that item is first created. The user can then add the additional items as required.
To allow users to select values from the Page Editor you can Use Sitecore EditFrame in PageEdit
The reason the item is being rendered as the raw value is because you need to get the item and then iterate over the target id's. There is an example of this here here
//Get a multilist field from the current item
Sitecore.Data.Fields.MultilistField multilistField = Sitecore.Context.Item.Fields["myMultilistField"];
if (multilistField != null)
{
//Iterate over all the selected items by using the property TargetIDs
foreach (ID id in multilistField.TargetIDs)
{
Item targetItem = Sitecore.Context.Database.Items[id];
litItemTitle = targetItem.DisplayName;
// Do something with the target items
// ...
}
}
You can use the following instead for the datasource of a repeater
Sitecore.Data.Fields.MultilistField multilistField = Sitecore.Context.Item.Fields["myMultilistField"];
Sitecore.Data.Items.Item[] items = multilistField.GetItems();

How to get a reference to the currently edited item when inside a custom field in Sitecore

In Sitecore I have created a custom field (via this recipe: http://sdn.sitecore.net/Articles/API/Creating%20a%20Composite%20Custom%20Field/Adding%20a%20Custom%20Field%20to%20Sitecore%20Client.aspx)
The field is for use in the content editor.
The custom field has a menuitem attached (the little textbutton rendered just above the field)
The custom field work as expected and the menuitem hooks into code in the custom field class as it should. However, the logic I need to implement for the menuitem requires that I get a reference to the item that is currently being edited by the user in the content editor.
However, to my surprise this doesn't work:
Sitecore.Context.Item
This does not give me the item that the user is currently editing, but instead the "content editor" item, which is always the same.
I would think there would simply be a property of some object in the API, but I can't find it.
If you are following this article then you will have defined a property on your control..
public string ItemID { get; set;}
.. this will be populated with the ID for the item you are editing. You should be able resolve the Item object from this ID using something like:
Sitecore.Data.Database.GetDatabase("master").GetItem(ItemID)
.. if you are just looking just for the value of the field you are editing you can use the base.Value field.
The best place to ask this would be on the developer forum, you should get a good response on there.
Though, taking a look through the Sitecore code, it looks like this might be what you want. Try reading it from the ViewState:
public string ItemID
{
get
{
return base.GetViewStateString("ItemID");
}
set
{
Assert.ArgumentNotNullOrEmpty(value, "value");
base.SetViewStateString("ItemID", value);
}
}
Stephen Pope is right, though there are more properties that you can 'automagiacally' retrieve from Sitecore. Some properties, just like ItemID are put on the field via reflection. There's also the ItemVersion and Source that can be useful for your custom controls.
If you're intereseted, take a peek inside the class Sitecore.Shell.Applications.ContentEditor.EditorFormatter, and especially its method SetProperties:
ReflectionUtil.SetProperty(editor, "ItemID", field.ItemField.Item.ID.ToString());
ReflectionUtil.SetProperty(editor, "ItemVersion", field.ItemField.Item.Version.ToString());