MVVM Light Bind value to list on button click

I am trying to build an simple universal app and I have followed the MVVM light setup. So far everything has fallen in place. Now I have a button and a listview on the same page. What I am trying to achieve is when I click on the button I want the list
view to show values. I have the list view bound to an observable collection and the button bound to RelayCommand. When I click the button the relay command is executing and returning values which I add to the observable collection, but myview is not getting
updated. when i directly create object in my design mode and in runtime the view is updating properly. Please provide any suggestion.
Code Section
View
<Page
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:CorrectMetroCardFare"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:ViewModel="using:CorrectMetroCardFare.ViewModel"
    x:Class="CorrectMetroCardFare.MainPage"
    mc:Ignorable="d"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
    DataContext="{Binding Main, Mode=OneWay, Source={StaticResource Locator}}">
    <Grid Height="640" Margin="0,0.333,0,-0.333" VerticalAlignment="Top">
        <TextBlock x:Name="title" Text="Metro Card Fare"  Margin="0,10,0,603"/>
        <TextBox x:Name="txtCurrentValue" InputScope="Number" PlaceholderText="Enter your Current Balance" Margin="0,53,0,0" Text="{Binding CurrentBalance, Mode=TwoWay}"/>
        <Button Content="Show Fares" HorizontalAlignment="Left" Margin="96,113,0,0" VerticalAlignment="Top" Command="{Binding ShowFaresCommand, Mode=OneWay}" CommandParameter="{Binding
CurrentBalance}" />
        <ListView x:Name="nbc" SelectionMode="Single" Margin="10,182,10,150" ItemsSource="{Binding Charges}">
            <ListView.Resources>
                <DataTemplate x:Key="FareTemplate">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <TextBlock Text="{Binding AmountToRecharge}" TextAlignment="Right" Grid.ColumnSpan="4"
Margin="0,0,-28,0" FontFamily="{StaticResource PhoneFontFamilyNormal}" FontSize="{StaticResource TextStyleLargeFontSize}"></TextBlock>
                        <TextBlock Text="{Binding BonusAmount}" TextAlignment="Right" Margin="118.333,0,-128.333,0"
Grid.Column="3" FontSize="{StaticResource TextStyleLargeFontSize}"/>
                        <TextBlock Text="{Binding NewBalance}" TextAlignment="Right" Margin="118,0,-229.333,0"
Grid.Column="3" FontSize="{StaticResource TextStyleLargeFontSize}"/>
                        <TextBlock Text="{Binding NumberofRides}" TextAlignment="Right" Margin="298,0,-308.333,0"
Grid.Column="3" FontSize="{StaticResource TextStyleLargeFontSize}"/>
                    </Grid>
                </DataTemplate>
                <ItemsPanelTemplate x:Key="FaresPanelTemplate">
                    <VirtualizingStackPanel Orientation="Vertical"></VirtualizingStackPanel>
                </ItemsPanelTemplate>
                <DataTemplate x:Key="headerTemplate">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="90" />
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <TextBlock Text="Amount to Recharge" Grid.Column="0" TextWrapping="WrapWholeWords" FontFamily="{StaticResource
PivotHeaderItemFontFamily}" FontSize="{StaticResource ContentControlFontSize}"/>
                        <TextBlock Text="Bonus Amount" Grid.Column="1" TextWrapping="WrapWholeWords" FontFamily="{StaticResource
PivotHeaderItemFontFamily}" FontSize="{StaticResource ContentControlFontSize}"/>
                        <TextBlock Text="New Balance" Grid.Column="2" TextWrapping="WrapWholeWords" FontFamily="{StaticResource
PivotHeaderItemFontFamily}" FontSize="{StaticResource ContentControlFontSize}"/>
                        <TextBlock Text="Number of Rides" Grid.Column="3" TextWrapping="WrapWholeWords" FontFamily="{StaticResource
PivotHeaderItemFontFamily}" FontSize="{StaticResource ContentControlFontSize}"/>
                    </Grid>
                </DataTemplate>
            </ListView.Resources>
            <ListView.HeaderTemplate>
                <StaticResource ResourceKey="headerTemplate"/>
            </ListView.HeaderTemplate>
            <ListView.ItemsPanel>
                <StaticResource ResourceKey="FaresPanelTemplate"/>
            </ListView.ItemsPanel>
            <ListView.ItemTemplate>
                <StaticResource ResourceKey="FareTemplate"/>
            </ListView.ItemTemplate>
            <ListView.DataContext>
                <ViewModel:MainViewModel/>
            </ListView.DataContext>
        </ListView>
    </Grid>
</Page>
View Model
     /// <summary>
                /// Sets and gets the DayList property.
                /// Changes to that property's value raise the PropertyChanged event.
                /// </summary>
                public ObservableCollection<BonusChargesValue> Charges
                    get
                        return _charges;
                    set
                        if (_charges == value)
                            return;
                       // RaisePropertyChanging(ChargesListPropertyName);
                        _charges = value;
                        RaisePropertyChanged(ChargesListPropertyName);
                public RelayCommand ShowFaresCommand
                    get;
                    set;
          /// <summary>
                /// Initializes a new instance of the MainViewModel class.
                /// </summary>
                public MainViewModel()
                    if (IsInDesignMode)
                        // Code runs in Blend --> create design time data.
                       // BonusChargesValue bnc = new BonusChargesValue();
                        _charges = new ObservableCollection<BonusChargesValue>();
                        _charges.Add(new BonusChargesValue { AmountToRecharge = 10.0, BonusAmount = 5, NewBalance = 15, NumberofRides = 5 });
                        _charges.Add(new BonusChargesValue { AmountToRecharge = 12.0, BonusAmount = 6, NewBalance = 17, NumberofRides = 6 });
                        _charges.Add(new BonusChargesValue { AmountToRecharge = 14.0, BonusAmount = 7, NewBalance = 19, NumberofRides = 7 });
                        _charges.Add(new BonusChargesValue { AmountToRecharge = 16.0, BonusAmount = 8, NewBalance = 21, NumberofRides = 8 });
                        _charges.Add(new BonusChargesValue { AmountToRecharge = 18.0, BonusAmount = 9, NewBalance = 23, NumberofRides = 9 });
                        _charges.Add(new BonusChargesValue { AmountToRecharge = 10.0, BonusAmount = 5, NewBalance = 15, NumberofRides = 5 });
                        _charges.Add(new BonusChargesValue { AmountToRecharge = 12.0, BonusAmount = 6, NewBalance = 17, NumberofRides = 6 });
                        _charges.Add(new BonusChargesValue { AmountToRecharge = 14.0, BonusAmount = 7, NewBalance = 19, NumberofRides = 7 });
                        _charges.Add(new BonusChargesValue { AmountToRecharge = 16.0, BonusAmount = 8, NewBalance = 21, NumberofRides = 8 });
                        _charges.Add(new BonusChargesValue { AmountToRecharge = 18.0, BonusAmount = 9, NewBalance = 23, NumberofRides = 9 });
                    else
                        // Code runs "for real"
                        Charges = new ObservableCollection<BonusChargesValue>();
                        ShowFaresCommand = new RelayCommand(GetValues, () => { return true; });
                      //  ShowFares = new RelayCommand(() =>
                           // Words = new string(Words.ToCharArray().Reverse().ToArray());
                        //_charges = new ObservableCollection<BonusChargesValue>();
                        //_charges.Add(new BonusChargesValue { AmountToRecharge = 10.0, BonusAmount = 5, NewBalance = 15, NumberofRides = 5 });
                        //_charges.Add(new BonusChargesValue { AmountToRecharge = 12.0, BonusAmount = 6, NewBalance = 17, NumberofRides = 6 });
                        //_charges.Add(new BonusChargesValue { AmountToRecharge = 14.0, BonusAmount = 7, NewBalance = 19, NumberofRides = 7 });
                        //_charges.Add(new BonusChargesValue { AmountToRecharge = 16.0, BonusAmount = 8, NewBalance = 21, NumberofRides = 8 });
                        //_charges.Add(new BonusChargesValue { AmountToRecharge = 18.0, BonusAmount = 9, NewBalance = 23, NumberofRides = 9 });
                        //_charges.Add(new BonusChargesValue { AmountToRecharge = 10.0, BonusAmount = 5, NewBalance = 15, NumberofRides = 5 });
                        //_charges.Add(new BonusChargesValue { AmountToRecharge = 12.0, BonusAmount = 6, NewBalance = 17, NumberofRides = 6 });
                        //_charges.Add(new BonusChargesValue { AmountToRecharge = 14.0, BonusAmount = 7, NewBalance = 19, NumberofRides = 7 });
                        //_charges.Add(new BonusChargesValue { AmountToRecharge = 16.0, BonusAmount = 8, NewBalance = 21, NumberofRides = 8 });
                        //_charges.Add(new BonusChargesValue { AmountToRecharge = 18.0, BonusAmount = 9, NewBalance = 23, NumberofRides = 9 });
                private void GetValues()
                    CalculateMetroFare cmcf = new CalculateMetroFare();
                    if (!string.IsNullOrWhiteSpace(CurrentBalance))
                        var chr = cmcf.Add2ExistingCard(Convert.ToInt32(CurrentBalance));
                        foreach (BonusChargesValue bncv in chr)
                            Charges.Add(bncv);
                    }`enter code here`
                   // return _charges;
VAravind ---------------------------------------------------------------------------------------------------------------------------------- Please click "Propose As Answer" if a post solves your problem or "Vote As Helpful" if a post
has been useful to you. Blog
VAravind ---------------------------------------------------------------------------------------------------------------------------------- Please click "Propose As Answer" if a post solves your problem or "Vote As Helpful" if a post
has been useful to you. Blog

I am not getting error but the Listview is not getting updated after the relay command
VAravind ---------------------------------------------------------------------------------------------------------------------------------- Please click "Propose As Answer" if a post solves your problem or "Vote As Helpful" if a post
has been useful to you. Blog

Similar Messages

  • Binding containe gets reset on button click ?

    Hi All
    In my page i am calling a method of AMIMpl class :
        public void refreshEmpTable(){
          String pRefresh = "Y";
          requeryViewObjectWithBindVariable(getEmp(), "bRefresh", pRefresh);
    and
        private void requeryViewObjectWithBindVariable(ViewObjectImpl pViewObjectImpl,
                                                       String pVariableName,
                                                       String pVariableValue) {
            ViewObjectImpl vo = pViewObjectImpl;
            vo.setNamedWhereClauseParam(pVariableName, pVariableValue);
            vo.executeQuery();
        }And i can see the following log
    <DebugDiagnostic> <print> [12497] DBG: afterActionPerformed :refreshEmpTable
    <ADFLogger> <begin> Refreshing binding container
    <DCBindingContainer> <internalRefreshControl> [12498] **** refreshControl() for BindingContainer :com_xyz_abc_ui_flow_om_omf_omf_prepareSessionSessionPageDef_WEB_INF_com_xyz_abc_ui_flow_om_om_xml_omf
    prepareSession() - default method of the taskFlow
    The button that triggers the refreshEmpTable() of impl class has partial submit as true. What i can see here is it is resetting the task flow. Can some some give a clue as to what i have done wrong here.
    thnks,
    JDev 11.1.1.4
    Edited by: in the line of fire on Jun 22, 2011 5:03 PM
    Edited by: in the line of fire on Jun 23, 2011 11:52 AM

    <ViewObject xmlns="http://xmlns.oracle.com/bc4j" Name="DeptView" Version="11.1.1.59.23" AutoRefresh="true"
    set this value to false if its there... in any of your VO

  • Passing values to jSP on button click

    Hello
    I have multiple delete buttons on the JSP page. What i want is to get the value as to which delete button was clicked. I am not sure if i shld have multiple names for the buttons. For now all have the same name since its inside a while loop.
    Also i want to confirm that the user really wants to delete the field. But i dont know how can i pass the value as well as the function at the same time through the onClick function.
    I tried type="hidden" for the field value and onClick="function" (where function is a javascript function that confirms if the user does want to delete the field). BUt in this case with type = hidden i get all the values corresponding to the field.
    Any pointers?
    heres the sample HTML code if it helps.. this one is just to show how the screen looks like. The actual JSP has the while loop.. which is also pasted below
    <HTML>
    <HEAD><TITLE>File Format Management</TITLE>
    <META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <SCRIPT language="JavaScript" type="text/javascript">
    <!--
    var errMsg = "";
    function confirmDelete(frm)
         var deleteSure = confirm("Are you sure you want to delete the fileType?");
         if (deleteSure)
                frm.submit();
         return deleteSure
    //-->
    </SCRIPT>
    </head>
    <body>
    <BR>
    <CENTER>
    <TABLE border="1" cellpadding="0" cellspacing="0" marginwidth=0 marginheight=0>
      <TR class="titlebar">
        <TD align="center">File Format Management</TD>
      </TR>
      <TR bgcolor="#cccccc">
        <TD>
    <B>File Types:</B>
    <p>The following file types are defined for this project.</p>
    <div align="center">
    <table cellpadding="3" cellspacing="0" border="0" width="100%">
    <tr><td>Filetype��</td><td># of fields��</td><th></th><th></th></tr>
    <tr><td>Demographics</td><td align="center">5</td><td><input type="submit" value="Edit"></a></td><td align="right"><input type="submit" value="Delete"></a></td></tr>
    <tr><td>Clinical</td><td align="center">17</td><td><input type="submit" value="Edit"></td><td align="right"><input type="submit" value="Delete"></td></tr>
    <tr><td>MS</td><td align="center">9</td><td><input type="submit" value="Edit"></td><td align="right"><input type="submit" value="Delete"></td></tr>
    <tr><td>HLA</td><td align="center">20</td><td><input type="submit" value="Edit"></td><td align="right"><input type="submit" value="Delete"></td></tr>
    <tr><td>SNP</td><td align="center">18</td><td><input type="submit" value="Edit"></td><td align="right"><input type="submit" value="Delete"></td></tr>
    <tr><td colspan="4"><input type="submit" value="Add new filetype..."></td></tr>
    </table>
    </div>
    <p align="center"><input type="submit" value="Return"></p>
    </td>
    </tr>
    </table>
    </body>
    </html>
    //actual while loop in JSP
    <table cellpadding="3" cellspacing="0" border="0" width="100%">
                <tr class="titleitem"><td>Filetype��</td><td># of fields��</td><th></th><th></th></tr>
                <% if ((!fileTypesFormats.equals(null)) && (fileTypesFormats.size() > 0))
                        Iterator keyIter = fileTypesFormats.entrySet().iterator();
                        while (keyIter.hasNext())
                            Map.Entry CurrentEntry = (Map.Entry) keyIter.next();
                            String formatNos = CurrentEntry.getKey().toString();
                            String fileTypeName = CurrentEntry.getValue().toString();
                            count++;
                 %>
                       <tr class="<%=htmlObj.getClassString(count)%>">
                         <td><input type="hidden" name="filetypeName" value="<%=fileTypeName%>"><%=fileTypeName%></td>
                         <td align="center"><%=formatNos%></td>
                         <td><input type="button" value="Edit" name="editBtn" onclick="location.href='edit_delete_filetype_format.jsp'"></a></td>
                         <td align="right"><input type="button" name="deleteBtn" value="Delete" onclick='confirmDelete(this.form)'></a></td>
                       </tr>
                 <% } } %>
                        <tr class="<%=htmlObj.getClassString(count)%>"><td colspan="4"><input type="button" value="Add new filetype..." onclick="location.href='edit_delete_filetype_format.jsp'"></td></tr>
            </table>

    Thanx for your help praveen
    I appreciate that.. but i misguided you. I am sorry abt that
    I want the value of the field beside the delete box to be passed to the Server side scripting.
    so if u see the html page u see something like this
    "Demographics 4 Edit Delete "
    "Clinical 3 Edit Delete"
    //note edit and delete are buttons
    Of this when the user clicks on Delete I want the jsp to pass Demographics value to the JSP.
    Right now it will pass all the values like "Demographics Clinical" . I probably have to give different names to the buttons...lets c
    Thanx for u r help

  • How to invoke a infopath form from list on button click

    Hi,
    I want to put a button on either the sharePoint page or on a Infopath form and on click of button, I need to open an already submitted form from the list (say with a unique id). 
    How can we do this in Infopath 2013. Please help.
    Thanks.

    Hi,
    There is already a reply in your another similar thread:
    https://social.msdn.microsoft.com/Forums/office/en-US/632bc3f8-330d-4d8b-910e-5df7cb202934/how-to-open-a-form-on-click-of-a-button-in-infopath?forum=sharepointcustomization
    Please check if it is helpful to you.
    Thanks
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • Bind Pivot SelectedIndex causes app random crash in WP 8.1 universal app [MVVM Light]

    I have an universal app for WP 8.1 with a page and a Pivot in it. The "SelectedIndex" property of the pivot is bind to a property in the VM like this (code in MainViewModel.cs):
    public object SelectedPivotIndex
    get { return this.selectedPivotIndex; }
    set
    if (this.selectedPivotIndex == value) return;
    this.selectedPivotIndex = value;
    RaisePropertyChanged(() => SelectedPivotIndex);
    Page code:
    <Pivot x:Name="ContentPivot"
    x:Uid="ContentPivot"
    SelectedIndex="{Binding SelectedPivotIndex, Mode=TwoWay}"
    >...</Pivot>
    The problem is from time to time i'm having app crash (in App.xaml.cs): "Unhandled exception" with type "COMEXCEPTION". This crash stop if I remove the bind of the "SelectedIndex" in the xaml, but I cannot understand
    why it ocurs. Sometimes even the debugger is not shown and the app closes without any error information. BTW I'm using MVVM Light, so the "glue" between the view (page) and the VM is set in the page:
    <Page
    DataContext="{Binding Source={StaticResource Locator}, Path=Main}"
    >
    EDIT:
    I'm able to reproduce the crash with this behavior: Open app, navigate to another page, come back to the pivot page (several times) and flip throught the pivotitems.

    I've solved the problem with a workaround. In page code behind:
    private void ContentPivot_SelectionChanged(object sender, SelectionChangedEventArgs e)
    var vm = this.DataContext as IPivotable;
    if (vm != null)
    vm.OnPivotItemChange(this.ContentPivot.SelectedIndex);
    The interface:
    public interface IPivotable
    void OnPivotItemChange(int pivotIndex);
    And finally the VM:
    public void OnPivotItemChange(int pivotIndex)
    try
    if (pivotIndex == 0)
    // Do stuff here...
    catch (Exception e)
    That's all, thanks for the... help?

  • Set a default value for a radio button populated with a List of value

    Hi,
    I am using jdeveloper 11.1.1.3.0. I need to set a default value for a radio button populated with a List of value(Yes/No). Here's the selectonechoice code.
    <af:selectOneRadio value="#{bindings.Code.inputValue}"
    label="#{bindings.Code.label}"
    required="#{bindings.Code.hints.mandatory}"
    shortDesc="#{bindings.Code.hints.tooltip}"
    id="sor1" autoSubmit="true"
    valuePassThru="true" layout="horizontal">
    <f:selectItems value="#{bindings.Code.items}" id="si1"/>
    </af:selectOneRadio>
    I want to have the selectonechoice set to No by default. In the previous versions, I set the default value in the base attribute VO. But it is not working in the new version.
    Thanks

    Hi,
    this should work in JDeveloper 11.1.1.3 the same as in 11.1.1.2. If it doesn't then it is better to file a bug than to work around it
    Frank

  • SetSelectedValue for multiple values in List Box

    Hi,
    I want to set the selectedValue for multiple values in the List Box. If i use setSelectedValue for all the values, it just highlights the last one.
    Can anyone tell me how do i highlight multiple values in the List Box?
    Scenario:
    I have one screen where the List Box and "Go" button is placed. When i select multiple values in the list box and hit "Go" it should display what i have selected in the List Box.
    Note: List Box is generated dynamically.
    Thanks,
    Naresh V

    setSelectedValue as the name indicates will set one value and in your case since you are using it multiple times it would pick the last value.
    When the user selects multiple values from the list box and clicks on Go you can capture those values in the controller for processing. What are you trying to achieve by resetting all the selected values on the same listbox ?

  • How can I get a List ID information using JScript on ribbon button click - SharePoint2010

    Dear All,
    I want to display the custom list ID column information on ribbon button click using a JScript.
    For This I have added a JScript in Layout folder in VS 2010 empty project solution and I have put
    the following Jscript code. While running and clicking the ribbon button, it seems like JScript is not
    invoking and not producing any result. It is like control is not going to Jscript file. How can I find out
    the issue???? can anyone please help me on anything wrong with my script or is
    it some-other problem which causes the blank result???
    It is a farm sharepoint2010 solution, debugging is not working in Visual Studio & IE!!!!
    Somebody please help, hard to find the error.....
    Please note the JScript Code: RibAlert.js
    <script>
    '//var siteUrl = '/sites/MySiteCollection';
    var siteUrl = 'http://a5-12457/AllItems.aspx';
    function retrieveListItems()
    var clientContext = new SP.ClientContext(siteUrl);
    var oList = clientContext.get_web().get_lists().getByTitle('Custom List');
    var camlQuery = new SP.CamlQuery();
    camlQuery.set_viewXml('<View><Query><Where><Geq><FieldRef Name=\'ID\'/>' +
    '<Value Type=\'Number\'>1</Value></Geq></Where></Query><RowLimit>10</RowLimit></View>');
    this.collListItem = oList.getItems(camlQuery);
    clientContext.load(collListItem);
    clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
    function onQuerySucceeded(sender, args)
    var listItemInfo = '';
    var listItemEnumerator = collListItem.getEnumerator();
    while (listItemEnumerator.moveNext())
    var oListItem = listItemEnumerator.get_current();
    listItemInfo += '\nID: ' + oListItem.get_id() +
    '\nTitle: ' + oListItem.get_item('Title') +
    '\nBody: ' + oListItem.get_item('Body');
    alert(listItemInfo.toString());
    function onQueryFailed(sender, args)
    alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
    </script>
    Please note the Elements.xml
    <?xml version="1.0" encoding="utf-8"?>
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <CustomAction
    Id="CustomRibbonButton"
    Location="CommandUI.Ribbon"
    RegistrationId="100"
    RegistrationType="List">
    <CommandUIExtension>
    <CommandUIDefinitions>
    <CommandUIDefinition
    Location="Ribbon.ListItem.Manage.Controls._children">
    <Button
    Id="Ribbon.ListItem.Manage.Controls.TestButton"
    Command="ShowAlert"
    Image16by16="http://a5-12457/IconLib/ICONBTN.jpg"
    Image32by32="http://a5-12457/IconLib/ICONBTN.jpg"
    LabelText="Comapre alert"
    TemplateAlias="o2"
    Sequence="501" />
    </CommandUIDefinition>
    </CommandUIDefinitions>
    <CommandUIHandlers>
    <!-- <CommandUIHandler Command="AboutButtonCommand" CommandAction="javascript:alert();" EnabledScript="javascript:enable();"/> -->
    <CommandUIHandler Command="ShowAlert" CommandAction="javascript:alert();" EnabledScript="return true;"/>
    </CommandUIHandlers>
    </CommandUIExtension>
    </CustomAction>
    <!-- <CustomAction Id="Ribbon.Library.Actions.Scripts" Location ="ScriptLink" ScriptSrc="/_layouts/DocumentTabTwo/RibButton.js" /> -->
    <CustomAction Id="Ribbon.Library.Actions.Scripts" Location ="ScriptLink" ScriptSrc="/_layouts/RibAlert.js" />
    </Elements>

    Dear All,
    I want to display the custom list ID column information on ribbon button click using a JScript.
    For This I have added a JScript in Layout folder in VS 2010 empty project solution and I have put
    the following Jscript code. While running and clicking the ribbon button, it seems like JScript is not
    invoking and not producing any result. It is like control is not going to Jscript file. How can I find out
    the issue???? can anyone please help me on anything wrong with my script or is
    it some-other problem which causes the blank result???
    It is a farm sharepoint2010 solution, debugging is not working in Visual Studio & IE!!!!
    Somebody please help, hard to find the error.....
    Please note the JScript Code: RibAlert.js
    <script>
    '//var siteUrl = '/sites/MySiteCollection';
    var siteUrl = 'http://a5-12457/AllItems.aspx';
    function retrieveListItems()
    var clientContext = new SP.ClientContext(siteUrl);
    var oList = clientContext.get_web().get_lists().getByTitle('Custom List');
    var camlQuery = new SP.CamlQuery();
    camlQuery.set_viewXml('<View><Query><Where><Geq><FieldRef Name=\'ID\'/>' +
    '<Value Type=\'Number\'>1</Value></Geq></Where></Query><RowLimit>10</RowLimit></View>');
    this.collListItem = oList.getItems(camlQuery);
    clientContext.load(collListItem);
    clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
    function onQuerySucceeded(sender, args)
    var listItemInfo = '';
    var listItemEnumerator = collListItem.getEnumerator();
    while (listItemEnumerator.moveNext())
    var oListItem = listItemEnumerator.get_current();
    listItemInfo += '\nID: ' + oListItem.get_id() +
    '\nTitle: ' + oListItem.get_item('Title') +
    '\nBody: ' + oListItem.get_item('Body');
    alert(listItemInfo.toString());
    function onQueryFailed(sender, args)
    alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
    </script>
    Please note the Elements.xml
    <?xml version="1.0" encoding="utf-8"?>
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <CustomAction
    Id="CustomRibbonButton"
    Location="CommandUI.Ribbon"
    RegistrationId="100"
    RegistrationType="List">
    <CommandUIExtension>
    <CommandUIDefinitions>
    <CommandUIDefinition
    Location="Ribbon.ListItem.Manage.Controls._children">
    <Button
    Id="Ribbon.ListItem.Manage.Controls.TestButton"
    Command="ShowAlert"
    Image16by16="http://a5-12457/IconLib/ICONBTN.jpg"
    Image32by32="http://a5-12457/IconLib/ICONBTN.jpg"
    LabelText="Comapre alert"
    TemplateAlias="o2"
    Sequence="501" />
    </CommandUIDefinition>
    </CommandUIDefinitions>
    <CommandUIHandlers>
    <!-- <CommandUIHandler Command="AboutButtonCommand" CommandAction="javascript:alert();" EnabledScript="javascript:enable();"/> -->
    <CommandUIHandler Command="ShowAlert" CommandAction="javascript:alert();" EnabledScript="return true;"/>
    </CommandUIHandlers>
    </CommandUIExtension>
    </CustomAction>
    <!-- <CustomAction Id="Ribbon.Library.Actions.Scripts" Location ="ScriptLink" ScriptSrc="/_layouts/DocumentTabTwo/RibButton.js" /> -->
    <CustomAction Id="Ribbon.Library.Actions.Scripts" Location ="ScriptLink" ScriptSrc="/_layouts/RibAlert.js" />
    </Elements>

  • How to assign a dynamic value to the value property of a button ?

    Hi Folks,
    I have a need, can i know how to assign a dynamic value to the value property of a button. Scenario is like follows...
    This is a struts based web application
    1. I have a file which consists of login user details (user name and his previlages) for a web application.
    2. I got those user details, into a List.
    3. When a user logged into the web app, in the home page there are few buttons. The type and number of buttons shown depends on the type of user/ user. (Buttons have different combination and the number of buttons available are not constant, they will vary from user to user).
    4. for each button, there will be a different action. I can pass the value of a button to an action class, but here button must have a dynamic value.
    Here is my test code:
    <%
    if (List != null)
    for (int i = 0; i <List.length; i++)
    %>
    <html:submit property="rduname" value= "<%=List%>" onclick="return submitRdu('<%=List[i] %>');"/>
    <%
    %>
    But my problem is how to assign a dynamic value to the value property of the button ( i know 'value= "<%=List[i]%>" ' will not work, just wanted show you guys).
    Thanks in advance,
    UV
    Edited by: UV_Dev on Oct 9, 2008 2:15 PM

    Let me try i know am not good at JSP but do we need double quotes here
    value= <%=List%>i think JSTL should help you about the dynamic thing                                                                                                                                                                                                                                                                                                                       

  • Adding value to List and Reading the list on submit

    Hi all,
    I want to create a page where it would have two region.
    Region 1 --> Contain the list of employee (report region)
    This will have a search box with java script enabled to perform search without submitting the page.
    And a link on the employee name, which when clicked the page should add the employee to the second region (List)
    Region 2 --> Contain the employee that is selected/clicked from the Region 1.
    Upon submission (ADD Button clicked) of the page. I will take the employee_ids in the list and add it into a table in the database.
    Does someone has an similar example I can take a look?
    Thanks.
    -Joel

    Hi Andy,
    Thanks for answering. That gives me idea how to deal with List.
    I have decided to go with creating a popup window with the region of list employee.
    when emp name is click it should trigger a page process.
    I took the javascript from Denes example here...
    SUBMIT REQUEST when using a Row link to navigate to a page
    javascript:f_setItem ('P1_HIDDEN_ITEM', #COLUMN_NAME#);doSubmit('SOME_REQUEST') ;
    It works fine if I don't add the 'doSubmit', i can check that the session state value is updated.
    When i do add the doSubmit, my page process is complaining that the item value is NULL which i found is true after i checked the session state value.
    I still don't have idea what's going on.
    Thanks.

  • How to display user define value in list screen from detail screen

    Hello Experts
    I am working on task in which i have to display the user define value on list screen. like i have one list list screen which have one button for add..once i click on add which navigate to detail screen and detail screen has two fields one for ID AND other for name and detail screen has one button for save once i put value for id and name and click on save button which will navigate to previous list screen and those values which should be display on list screen.
    Regards:
    Sumit

    Hi Sumit,
    To navigate to the Master page on button click , you need some thing like,
    oSplitApp.toMaster("masterpage_id");
    to understand the navigation for Master/Detail page , have a look at,
    http://help.sap.com/saphelp_uiaddon10/helpdata/en/df/adb6b7247e4826b0fcde472b029840/content.htm
    Also to pass value from Detail page to Master page, you can use a Global variable to store your values on click of the Save button. For eg. You may have a global JS file which both Master and Detail page can access like App.Js, Application.JS etc.
    After navigating to the Master page, you can read the Global variables and show it on your Master page.

  • How to populate values in List Box in Adobe form

    Hi,
    How to populate values in List box in adobe forms?
    Thanks
    RB

    if you want to display a fixed values in the dropdown you can use list box ui and can specify values there
    or if u want to display values from the context node of the webdynpro
    1. Drag and drop a Value Help Drop-down List element from the Web Dynpro Library tab to the Body Pages pane.
    2. Drag and drop your node from the Data View tab onto it. This action binds the layout element to the corresponding node.
    with regards
    shanto aloor

  • How to get the bind value of a portlet in a page.

    I want to get the bind value of a portlet on a page. Can you tell me how can I get that.
    I used :
    portal30.wwv_name_value.get_string( l_arg_names, l_arg_values, '');
    It works ok when we run the report alone .But when we add the report as a portlet in page , it does not return any value. Can you tell me which Api does it.
    null

    Here is an example...
    var originalUnits = app.preferences.rulerUnits;
    app.preferences.rulerUnits = Units.PIXELS;
    var doc = activeDocument;
    var Colour1 = GetHexColour(eyeDropperRGB(1,doc.height-1));
    var Colour2 = GetHexColour(eyeDropperRGB(20,doc.height-5));
    var Colour3 = GetHexColour(eyeDropperRGB(40,doc.height-14));
    alert("Colour 1 = " +Colour1 + "\rColour 2 = " +Colour2 + "\rColour 3 = " +Colour3);
    var decColour = eyeDropperRGB(40,doc.height-14);
    alert("Red = " +decColour[0] + "\rGreen = " +decColour[1] + "\rBlue = " +decColour[2]);
    app.preferences.rulerUnits = originalUnits;
    function GetHexColour(reqHex){
    var out='';
    for(No in colours = reqHex){
    out = out.concat(zeroPad(d2h(reqHex[No]),2));
    return out;
    function eyeDropperRGB(x,y) {
    var x2 = x + 1;
    var y2 = y + 1;
    var out = new Array(3);
    activeDocument.selection.select([[x,y], [x2,y], [x2,y2], [x, y2]], SelectionType.REPLACE, 0, false);
    for(ch in list = ["Red", "Green", "Blue"]) {
    histogram = activeDocument.channels[list[ch]].histogram;
      for (i = 0; i <= 255; i++) {
       if (histogram[i]) {
        out[ch] = i;
        break;
      return out; 
    function d2h(d) {return d.toString(16);}
    function zeroPad(n, s) {
       n = n.toString();
       while (n.length < s)  n = '0' + n;
       return n;

  • Using an array to assign values to 36 radio buttons

    Okay, here's another doozy for y'all.
    As some of you know, I'm trying to create a character creation program for D&D. When we roll ability scores, we roll 3 sets of 6 rolls, rolling 4 six-sided dice, rerolling 1s and dropping the lowest number, then add the highest 3 rolled numbers together.
    Great! Got that part done!
    The next thing I'm having some issues with is transferring those numbers to radio button text property. What I have done is created a form that has the rolled values in listboxes so the user can see what was rolled. They can only choose one "set"
    of rolls, so each set of 6 rolls is in a separate listbox. I can get the values from the listbox to an array, but I can't figure out how to get the values from an array to the radio buttons on the next form in the program.
    The next form in the program has 6 group boxes, each labeled with a different ability score name (ie: Strength, Dexterity, etc.). Also in each group box are 6 radio buttons. Each radio button in each group box needs to have the same values. For example,
    the first listed radio button in each group box needs to have the first value listed in the list box on the previous page. The second listed radio button in each group box needs to have the second value listed in the list box, and so on. I want it
    to automatically load, but I'll settle for ANY load at the moment!
    The other thing is that I don't want to write 36 lines of code for each group box's radio buttons! I would like to be able to populate the values with a loop. So, the biggest question is how to create an array containing all 36 radio buttons, then assign
    my list box values to them according to their position in the multidimensional array.
    Here is a tidbit so you'll have an idea what I'm looking at.
    list box 1 has values 17, 18, 8, 12, 15, and 13. I want the radio buttons in each group box on the second form to be 17 for the 1st radio button, 18 for the 2nd radio button, 8 for the 3rd radio button, 12 for the 4th radio button, 15 for the 5th radio
    button, and 13 for the 6th radio button.
    Any ideas?

    The array of radio buttons:
    radGr1_1
    radGr1_2
    radGr1_3
    radGr1_4
    radGr1_5
    radGr1_6
    radGr2_1
    radGr2_2
    radGr2_3
    radGr2_4
    radGr2_5
    radGr2_6
    radGr3_1
    radGr3_2
    radGr3_3
    radGr3_4
    radGr3_5
    radGr3_6
    radGr4_1
    radGr4_2
    radGr4_3
    radGr4_4
    radGr4_5
    radGr4_6
    radGr5_1
    radGr5_2
    radGr5_3
    radGr5_4
    radGr5_5
    radGr5_6
    radGr6_1
    radGr6_2
    radGr6_3
    radGr6_4
    radGr6_5
    radGr6_6
    Those listed with “radGr1” are in the first group box labeled grpST, “radGr2” are in the second group box labeled grpDX, and so on (grpCN, grpIQ, grpWS, grpCH). What I want the code to do is change the labels of the radio buttons so that the text displayed
    in everything with a suffix of “_1” is filled with the first number in the selected listbox. For example, if I select the first list box, the other 2 are cleared and only the 6 numbers in the first one are used for the rest of the program. If those numbers
    are 12, 13, 14, 15, 17, and 11, then everything with _1 at the end should have “12”, everything with _2 should have “13”, and so on. What I don’t want to have to do is initialize 36 elements, then have 6 different selections for each group box. I tried to
    attach an image, but it wouldn’t let me…something about verifying my account or something…
    Can I suggest a different layout?  It seems like the status selection process is over-complicating the code... please consider this form layout:
    Once the user has selected the set of rolls they want you use, you can then just work with that single listbox.  The radio buttons let them select a particular stat and the listbox lets them select a value.  The "<-" button then assigns
    the selected value to the selected stat, and removes it from the listbox.  The "->" button clears the selected stat and returns the value to the listbox.  The code is something like:
    Public Class Form1
    Private Sub SetButton_Click(sender As Object, e As EventArgs) Handles SetButton.Click
    If ChosenRollsListBox.SelectedIndex > -1 Then
    Select Case True
    Case StrRadioButton.Checked
    If Not StrLabel.Text = "_" Then
    ChosenRollsListBox.Items.Add(StrLabel.Text)
    End If
    StrLabel.Text = ChosenRollsListBox.SelectedItem.ToString
    ChosenRollsListBox.Items.RemoveAt(ChosenRollsListBox.SelectedIndex)
    Case DexRadioButton.Checked
    If Not DexLabel.Text = "_" Then
    ChosenRollsListBox.Items.Add(DexLabel.Text)
    End If
    DexLabel.Text = ChosenRollsListBox.SelectedItem.ToString
    ChosenRollsListBox.Items.RemoveAt(ChosenRollsListBox.SelectedIndex)
    Case ConRadioButton.Checked
    If Not ConLabel.Text = "_" Then
    ChosenRollsListBox.Items.Add(ConLabel.Text)
    End If
    ConLabel.Text = ChosenRollsListBox.SelectedItem.ToString
    ChosenRollsListBox.Items.RemoveAt(ChosenRollsListBox.SelectedIndex)
    Case IntRadioButton.Checked
    If Not IntLabel.Text = "_" Then
    ChosenRollsListBox.Items.Add(IntLabel.Text)
    End If
    IntLabel.Text = ChosenRollsListBox.SelectedItem.ToString
    ChosenRollsListBox.Items.RemoveAt(ChosenRollsListBox.SelectedIndex)
    Case WisRadioButton.Checked
    If Not WisLabel.Text = "_" Then
    ChosenRollsListBox.Items.Add(WisLabel.Text)
    End If
    WisLabel.Text = ChosenRollsListBox.SelectedItem.ToString
    ChosenRollsListBox.Items.RemoveAt(ChosenRollsListBox.SelectedIndex)
    Case ChaRadioButton.Checked
    If Not ChaLabel.Text = "_" Then
    ChosenRollsListBox.Items.Add(ChaLabel.Text)
    End If
    ChaLabel.Text = ChosenRollsListBox.SelectedItem.ToString
    ChosenRollsListBox.Items.RemoveAt(ChosenRollsListBox.SelectedIndex)
    End Select
    End If
    End Sub
    Private Sub ClearButton_Click(sender As Object, e As EventArgs) Handles ClearButton.Click
    Select Case True
    Case StrRadioButton.Checked
    If Not StrLabel.Text = "_" Then
    ChosenRollsListBox.Items.Add(StrLabel.Text)
    StrLabel.Text = "_"
    End If
    Case DexRadioButton.Checked
    If Not DexLabel.Text = "_" Then
    ChosenRollsListBox.Items.Add(DexLabel.Text)
    DexLabel.Text = "_"
    End If
    Case ConRadioButton.Checked
    If Not ConLabel.Text = "_" Then
    ChosenRollsListBox.Items.Add(ConLabel.Text)
    ConLabel.Text = "_"
    End If
    Case IntRadioButton.Checked
    If Not IntLabel.Text = "_" Then
    ChosenRollsListBox.Items.Add(IntLabel.Text)
    IntLabel.Text = "_"
    End If
    Case WisRadioButton.Checked
    If Not WisLabel.Text = "_" Then
    ChosenRollsListBox.Items.Add(WisLabel.Text)
    WisLabel.Text = "_"
    End If
    Case ChaRadioButton.Checked
    If Not ChaLabel.Text = "_" Then
    ChosenRollsListBox.Items.Add(ChaLabel.Text)
    ChaLabel.Text = "_"
    End If
    End Select
    End Sub
    End Class
    This may not suit your requirements but I thought it was at least worth considering an alternate design that would be much easier to implement.
    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

  • Binding Drop Down Lists

    Hello,
    I am trying to figure out how i can bind drop down lists. I want it so if you choose a certain selection in drop down list 1, then you are only able to pick a certain selection out of drop down 2. So basically each selection in drop down 1 will give you different options to select in drop down 2. Sorry if i made that really confusing. Thanks
    -Aaron-

    Hi,
    Here is a mock-up version of the spreadsheet.
    The first dropdown has the nine categories set in the Object / Field tab. Also have a look in the Object / Binding tab as there are values specified for each of the nine categories. These will be used later in the script.
    The second dropdown does not have any values specified in the Object / Field tab.
    Instead there is script in the exit event of the first dropdown. This is a switch statement that first of all looks at the bound value ("9030") of the choice that the user has made ("9030 National Marketing"). The statement then looks at each case until it gets to one that matches; then it runs the script for that case and then breaks from the switch statement.
    Each case starts off with:
    DropDownList2.clearItems();
    DropDownList2.rawValue = null;
    This is important because this clears the list in dropdown2 and sets its value to null. These two lines are then followed by a series of addItem() script which goes through all of the types in that category.
    I have scripted all of 9030 and the first five lines of 9031. This should get you out of the traps. It is a bit of a pain, but just copy and paste downwards.
    Each case ends with a "break;" and the last "}" closes the switch statement.
    Good luck,
    Niall

Maybe you are looking for