MS CRM 2013 - Get Selected Records of a Subgrid From a Button - JAVASCRIPT - dynamics-crm-2013

I added a button on my subgrid named "lots_associes", and I want by clicking on this button javascript recover all selected records.
I tried all the solutions proposed as http://vikramxrm.blogspot.fr/2013/11/read-subgrid-records-ms-crm-2013-using.html
But it seems that the functions "getElementById ('lots_associes')" do not work while "Xrm.Page.ui.controls.get('lots_associes')" works. I have the good name of the grid.
Do you have any ideas?

In 2011, it was the Ribbon's job: I assume 2013 would be the same (despite the different look'n'feel).
You had to use CrmParameter to have the IDs of the selected records:
// in the RibbonDiffXml
<JavaScriptFunction FunctionName="YourFunc" Library="YourLibrary">
<CrmParameter Name="MyRecordIDs" Value="SelectedControlSelectedItemIds" />
</JavaScriptFunction>
//The corresponding function would look like
function YourFunc(recordIDs){
// recordIDS will be filled with the IDs of the selected records
}
Here is the reference for CrmParameter (it says it applies to 2011 but there is no equivalent for 2013 so I believe this info is still valid)
On a side note, never use getElementById (it's not supported: no support from microsoft and any rollup might break your code).

Related

want yadcf filter multiselect options based on another filter value

I am using yadcf 0.9.3.
I have data similar to the following
race1,event1,otherfields
race1,event1,otherfields
race1,event2,otherfields
race1,event2,otherfields
race2,event3,otherfields
race2,event4,otherfields
I want to be able to select race (e.g., race1) with one filter, then have event filter multiselect show only appropriate events (in this case event1, event2). And when I select another race (e.g., race2) only those events are shown (in this case event3, event4)
I tried cumulative_filtering = true, but that doesn't work for my use case. First of all with cumulative_filtering = true, once I've selected race1, I can't change the selection to race2, also I have read other stackoverflow questions which noted that multiselect doesn't work well with cumulative_filtering because once the first options is chosen the others disappear.
This could work similar to datatables Editor dependent(), I suppose.
Is there any way to achieve this with the current or more recent yadcf? I reviewed 0.9.3.beta.26 (well master/latest, see https://github.com/vedmack/yadcf/blob/94a95338e697f972fa64bc79e4276fc35c8f3c40/src/jquery.dataTables.yadcf.js), and I am not sure if the new features would work (although it's possible something can be done with exRefreshColumnFilterWithDataProp -- note doc goes off the right side of the page when reviewing through github, so formatting could be improved).
If exRefreshColumnFilterWithDataProp should be used, is there a best practice to determine the values for one column (in my case events) given a filter in another (in my case races)?
UPDATE1 with codepen test case: https://codepen.io/louking/pen/VOrYjr

Xpages - Dojo Value Picker [multiple choice, other db, search function]

I need to build a dojo value picker that has the following capabilities:
1) Be able to choose views from a different DB
2) Be able to choose multiple values
3) Be able to have the user search for a value
I cannot figure out how to get all three.
A simple value picker appears to not support search.
If I user a dominoViewValuePicker, I cannot have both dojo types:
extlib.dijit.PickerCheckbox
and
extlib dijit pickerlistsearch
Can someone tell me what I am doing wrong?
Thanks to Paul and others for helping. I did get this to work by using the dominoViewValuePicker. See my example below, which I hope could help someone else.
<xe:valuePicker id="valuePicker1"
dialogTitle="Choose From This List" pickerIcon="/picker.png"
for="Approvers" dojoType="extlib.dijit.PickerListSearch">
<xe:this.dataProvider>
<xe:dominoViewValuePicker viewName="(YOURVIEWNAME)">
<xe:this.databaseName><![CDATA[#{javascript:var serv:String = session.getCurrentDatabase().getServer();
serv + "!!" + "YOURDB.nsf";}]]></xe:this.databaseName>
</xe:dominoViewValuePicker>
</xe:this.dataProvider>
</xe:valuePicker>
I don't think you can have both dojo types. But with extlib.dijit.pickerlistsearch, double-clicking selects entries and does allow multiple to be selected. See http://www.intec.co.uk/extension-library-value-picker-and-extlib-dijit-pickerlistsearch/

Accessing the changed state of a radio button using rollout creator (Maxscript)

I've run across another issue using the dynamic rollouts. I'd like to add a handler for when a radio button group's selection is changed. Here is what I have:
--Instantiate a new dynamic rollout object
dro = rolloutCreator "CustomParamsRollout" "Edit Custom Parameters"
--Begin building rollout
dro.begin()
--Create an array to hold the names of the radio button options
dro.addLocal "RadioOptions" init: #("Predefined", "Custom")
--add control --type --label --displayed name --labels --alignment
dro.addControl #radiobuttons #rdo_1 "radio_1" paramStr: "labels:RadioOptions align:#left"
--Add a handler for the first radio button
dro.addHandler #rdo_1 #changed filter:on paramStr:"1" codeStr:"MessageBox #Hey#"
createDialog (dro.end())
The error I keep getting is:
Compile error: Bad number or time syntax
In line: on rdo_1 changed 1do
Whenever I click on a radio button. I'm most certain that my syntax is poorly written, as that has been the biggest hangup in this project so far. Any helpful hints would be appreciated.
Thank you.
Since 3ds Max 2012 you need to add an extra space to the parameter string (in Max 2011 and earlier version it works without glitches. So instead of paramStr:"state" it would have to be paramStr:"state " – note that using integer for a name of variable will not work, rollout handlers don't in any way work like pattern matching, you need to handle different parameters inside the handler scope.

dojox.grid.DataGrid: how to access data from a click event?

I'm using Dojo 1.5 (including dojox). I have a dojox.grid.DataGrid where each row represents a user. When I click a row, I want to redirect to a URL like /users/USER_ID. The user ID is one of the fields in the grid, so all I need to do in my onRowClick callback is to grab the user ID for the row that was clicked.
The click event contains a rowIndex property, and, indeed, I found a (rather old) post elsewhere that suggested I should be able to do:
var row = dijit.byId('grid').model.getRow(e.rowIndex);
/* (Then grab the 0th field of the row, which is the user ID.) */
(Sorry, I've since lost the URL.)
But my grid object has no model attribute. What's up with that? Has the API changed? (My grid certainly is populated with data, which I can see, click, sort by column, et cetera).
So I'm stuck for now. Note, BTW, that it won't work to use rowIndex to directly access the grid's underlying dojo.data.ItemFileReadStore. That's because the grid is sortable, so there's no guarantee that the grid's rows will be in the same order as the store's.
Any hints would be deeply appreciated. I hope that the question is clear, and sufficiently general that any answers can help others in my predicament. Many thanks.
I have a similar scenario and I grab the value like this:
onRowClick: function(e) {
open_link(my_grid._getItemAttr(e.rowIndex, 'object_path'));
}
In this case my_grid is a reference to the datagrid and object_path is the column where I store the path to the object. open_link is of course a custom function of mine that as it implies, requests a server path.
So just change the specifics to suite your case and you should be fine.

Jquery live does not seem to work in nested calls

I am encountering a problem of jquery live function not consistently working for me (or that what I think).
I have the same html form which is used for both adding new comment and editing an existing one; this form is propagated using a php code at the server side through a GET call. The two forms are displayed in two different tabs (tab1: adding a comment, tab2: listing the comments; tab3: edit a comment selected in tab2) based on the tab selection. The "Add comment" form appears as the main content of the tab1; however, the 'edit' form appears based on the selection of the comment that needs to be edit in tab2, so let assume that the "edit comment" form appears as tab3. The below code work perfectly for tab1 when the form is the main content of that tab; but it doesn't work consistently when it is the main content of tab3, which is showed based on which comment need to be edit in tab2.
$("input.sample_radio").live('change',function(){
if ($(this).val() == 'no')
$('#sample_table').hide();
else if ($(this).val() == 'yes')
$('#sample_table').show();
return false;
});
If you can provide me with some thoughts, it would be appreciated. My observations were:
I used $("input[name='sample_radio']") but this didn't work for the form of tab3 because it always end up at the form of tab1
by using $("input.sample_radio") I assumed all the classes of type 'sample_radio' would work, but it not working either.
live is supposed to bind events to the new elements added to the DOM tree after jquery calls, but it seems this is not the case for me.
Thanks
Following the suggestion of Mark Schultheiss
Look into .delegate() which was presented specifically to address this by allowing you to specify a context.
I managed to solve this issue by binding the event to the selected parents (tab1 and tab3) of the radio buttons and then filtering based on the selector which is here is the name of the radio button element and as shown below:
$('#tab1,#tab3').delegate('input[name="policy_radio"]','change',function(){
if ($(this).val() == 'no')
$('.policy_table').hide();
else if ($(this).val() == 'yes')
$('.policy_table').show();
return false;
});
Thanks for pointing me to this point.
By using .live you have ran into one of it's challenges. When you change the selection context you prevent it from working properly.
Look into .delegate() which was presented specifically to address this by allowing you to specify a context.
See this post for some notes on delegate from Brandon Aaron: http://brandonaaron.net/blog/2010/03/4/event-delegation-with-jquery
And see this nice one on context: http://brandonaaron.net/blog/2009/06/24/understanding-the-context-in-jquery