Jgrid defining custom formatter dynamically - jquery-ui

I have a grid with colModel defined as:
colModel: [
...
{name:'price', index:'price', width:60, align:"center", editable: true},
...
]
After the grid is created I want to bind a custom formatter with the column. How can I achieve that.

You can use setColProp method for example to modify some specific column in colModel. You can dynamically modify the most properties inclusive formatter. It's important that the formatter will be used during filling the <tbody> (the data part) of the grid. Thus the modification of the formatter will be seen after the next filling the grid. Thus one can make modification of formatter inside of beforeProcessing callback or one should trigger reloadGrid after the modification. I recommend you to read the old answer for more information and an example of the implementation.

Related

Breezejs non scalar complex type not updating properly when refetched from server

We are running into an issue with updating non scalar complex type.
Our simplified metadata looks like this
Table
shortName: 'Table',
defaultResourceName: "/table",
dataProperties: {
name: { max: 50, required: true },
description: { max: 500},
columns: {complexType: 'Column', isScalar: false}
...
}
Column
shortName: 'Column',
isComplexType: true,
dataProperties: {
name: { max: 50, required: true },
description: { max: 500 },
...
}
Our backend is document based nosqldb.
In the UI, we display all the tables and its columns in a tree like structure. User can click on a Table name or column and edit it's properties in a property editor. Table and Column have separate editors, even though internally they are part of the same object.
Initially when we display the tree we only fetch limited no. of dataproperties of the json, only the ones that are required to be displayed in the tree. But when the user clicks on a particular table or a column we fetch the entire table (columns are complex types) from the server and update the cache to display them in the editor.
We are using knockout as the model library so all the properties are knockout observables. We are passing the same breeze entity objects to viewmodels of these editors as well as the tree.
If the user clicks on a table in the tree, and edits name or description in the editor, we are seeing table name in the tree is also changing as it should, since they are both the same observable. But when I click on a column name in the tree, and edit the column name in the editor, I do not see the change getting reflected in the tree.
What I think is happening here is, when I am re-querying the same object from the server to display in the editor, table name which a simple property is being updated with the new value from the server, but column name which is part of complex object, is actually getting replaced with new values from server, since each complex object in the array itself is being replaced. So it seems like tree and editor has different obsrevables.
Funny thing is, if after clicking on a particular column and having it displayed in the editor, I move to a different module (we are using spa), and then come back to the original module again, then if I click on the same column again and update the name, this time the change is getting reflected in the tree. But not the first time.
Could this be a bug, or am I missing something? Is there a workaround?
We are using breeze js 1.5.6
Thanks!

Dynamic Tag Management - Storing

We're in the process of moving to DTM implementation. We have several variables that are being defined on page. I understand I can make these variables available in DTM through data elements. Can I simply set up a data elem
So set data elements
%prop1% = s.prop1
%prop2% = s.prop2
etc
And then under global rules set
s.prop1 = %s.prop1%
s.prop2 = %s.prop2%
etc
for every single evar, sprop, event, product so they populate whenever they are set on a particular page. Good idea or terrible idea? It seems like a pretty bulky approach which raises some alarm bells. Another option would be to write something that pushes everything to the datalayer, but that seems like essentially the same approach with a redundant step when they can be grabbed directly.
Basically I want DTM to access any and all variables that are currently being set with on-page code, and my understanding is that in order to do that they must be stored in a data element first. Does anyone have any insight into this?
I use this spec for setting up data layers: Data Layer Standard
We create data elements for each key that we use from the standard data layer. For example, page name is stored here
digitalData.page.pageInfo.pageName
We create a data element and standardize the names to this format "page.pageInfo.pageName"
Within each variable field, you access it with the %page.pageInfo.pageName% notation. Also, within javascript of rule tags, you can use this:
_satellite.getVar('page.pageInfo.pageName')
It's a bit unwieldy at times but it allows you to separate the development of the data layer and tag manager tags completely.
One thing to note, make sure your data layer is complete and loaded before you call the satellite library.
If you are moving from a legacy s_code implementation to DTM, it is a good best practice to remove all existing "on page" code (including the reference to the s_code file) and create a "data layer" that contains the data from the eVars and props on the page. Then DTM can reference the object on the page and you can create data elements that map to variables.
Here's an example of a data layer:
<script type="text/javascript">
DDO = {} // Data Layer Object Created
DDO.specVersion = "1.0";
DDO.pageData = {
"pageName":"My Page Name",
"pageSiteSection":"Home",
"pageType":"Section Front",
"pageHier":"DTM Test|Home|Section Front"
},
DDO.siteData = {
"siteCountry":"us",
"siteRegion":"unknown",
"siteLanguage":"en",
"siteFormat":"Desktop"
}
</script>
The next step would be to create data elements that directly reference the values in the object. For example, if I wanted to create a data element that mapped to the page name element in my data layer I would do the following in DTM:
Create a new data element called "pageName"
Select the type as "JS Object"
In the path field I will reference the path to the page name in my data layer example above - DDO.pageData.pageName
Save the data element
Now this data element can be referenced in any variable field within any rule by simply typing a '%'. DTM will find any existing data elements and you can select them.
I also wrote about a simple script you can add to your implementation to help with your data layer validation.Validate your DTM Data Layer with this simple script
Hope this helps.

Big Commerce Custom Fields

I'm planning on allowing a client to provide a couple codes for each product that I'll need to reference with Javascript on the product pages.
Basically my plan was to use the Big Commerce's 'custom fields' to do so, but I'm having trouble spitting out the custom fields onto the product pages. I've been looking all over for some type of GLOBAL variable that allows me to reference custom fields, but I'm coming up dry. I would think there would be some type of GLOBAL array with all the custom fields in it, or a way to reference them by name directly.
Am I blind, or is there just no way to do this directly in the BC template file?
Thanks.
In Bigcommerce the custom fields can generally be found within the ProductOtherDetails.html Panel which contains a Snippet named ProductCustomFieldItem.html. This snippet has the markup for each custom field that the system outputs.
Inside of the ProductCustomFieldItem.html Snippet are the two codes you are looking for: %%GLOBAL_CustomFieldName%% and %%GLOBAL_CustomFieldValue%%.
I ran into this as well - given that it's quite a long time later, I'm supposing there's no better answer - a decent amount of searching turned up nothing useful as it seems all you can do is output the full set of custom fields as a set of divs.
So, I output them into a div which was hidden:
<div id="fpd-custom-fields" style="display:none;">
%%SNIPPET_ProductCustomFields%%
</div>
and then set up a javascript function to get the value based on the name:
function getCustomFieldValue(label)
{
var value = '';
$('#fpd-custom-fields div.Label').each(function()
{
if($(this).text().toLowerCase() == (label.toLowerCase() + ':'))
{
value = $('div.Value', $(this).parent()).text().trim();
}
});
return value;
}
Doesn't feel quite right as it's not a very clean solution, but was the best I could come up with unfortunately!

How to localize selectOptions on the visual force page

I am trying to localize selectOptions on the Visual Force page.
Here is the .class code snippet:
List<SelectOption> options = new List<SelectOption>();
List<MyOption__c> dropDownValues = [SELECT Id, Display_Label_Name__c FROM MyOption__c];
for (MyOption__c val : dropDownValues) {
// Display_Label_Name__c field is the label from *.labels that needs to be translated
options.add(new SelectOption(val.Id, val.Display_Label_Name__c));
}
Here is the .page code snippet:
<apex:selectList value="{!myVal}">
<apex:selectOptions value="{!options}"/>
</apex:selectList>
Right now the dropdown displays the Display_Label_Name__c verbose. I am trying to see how I can display the translated version from the .labels file. Is it possible? If not, what's the work around?
Thank you for your responses!
All localisation of page text can be done with Custom Labels.
Enable the translation workbench with the languages you require.
Create labels for all the localisible text on the page.
Replace the page text with the labels.
Add a translation for each label.
Change your profile langauge to test.
But for your case you pull the select option text from a custom object. If the values of the select list are not expected to change frequently, less than once a week or so, then I would change to using custom labels.
Otherwise, you lose the value of Salesforce automatic language selection and have to implement something yourself.
I would recommend extending the custom object MyOption__c to have columns for all the supported languages. You could use an if/else block or dynamic apex to select the select option text.
Sample using Dynamic Apex
string language = ParseForSupportedLangauges(UserInfo.getLanguage()); // includes __c
list<sobject> dropDownValues = Database.query('SELECT Id, '+language+' FROM MyOption__c');
for (sobject val : dropDownValues) {
options.add(new SelectOption(val.get('Id'), val.get(language)));
}
ParseForSupportedLangauges() would be a custom method that checks for supported languages and assigns the default when necessary.
EDIT
Turns out there is a solution: Don't look for something until you need it, right?
Introduced in Spring '12 is the ability dynamicaly select the label to display suing array syntax. Also, the ability to create visualforce components from the controller was added but using the array syntax would be sufficient for your problem. This method would allow you to select the labels you want by using the query results from MyOption__c.
Using a repeat in visualforce to loop over the query results
<apex:repeat value="{!displayResultsValues}" var="labelName">
<apex:outputText value="{!$Label[labelName]}"/>
</apex:repeat>
Here is a good article to show the usage and syntax.

DevExpress XtraScheduler custom mapping

Is it possible to make some conversion while mapping?
SchedulerStorage schedulerStorage =
schedulerControl1.Storage;
schedulerStorage.Appointments.Mappings.Start
= "StartTime";
For example I want to add one hour to Appointment.Start, but I don't want to change "StartTime" property get{} of my business object.
Generally, we did not consider such scenario of using the XtraScheduler when designed it. So, this feature is not supported. I can only suggest that you create a new field in the DataSource which will contain an updated value of the StartTime field and map the Start property to it....

Resources