jeudi 29 juin 2023

What is this element called? Two dimensional checkbox/radiobox?

I'm developing a Flutter app and I'm trying to find what this is called:

Thing I'm trying to find

Essentially, it's a checklist that only allows one input and is two dimensional.

Selection showed

In this image, the top left box is selected.

I'd appreciate any help in trying to find what this element is called.




mercredi 28 juin 2023

Automatically check/uncheck one checkbox if another is checked/unchecked in R Shiny

I have a Shiny app in which users may choose a number of textInput boxes based on a numericInput, which also determines the number of checkbox pairs. When these checkboxes are marked, the text in the textInput is added to separate lists depending on which checkbox is marked. In this app, everything that exists in the normalized_controls_coll list must also exist in the controls_coll list, but not necessarily vice versa. I have made an attempt at making it so that the normCTLcheckbox will automatically be checked if CTLcheckbox is checked, and that normCTLcheckbox will be unchecked if CTLcheckbox is unchecked.

Below is my best attempt, although this dependency does not happen. Does anyone have any ideas for this? Thanks!

library(shiny)
library(shinyWidgets)
library(htmlwidgets)

########## User interface ##########
ui = fluidPage(
  
  navbarPage("",
             
             #### Tab Panel 3 ####
             tabPanel("",
                      fluidRow(
                        sidebarPanel(
                          ####Conditions information####
                          #Determine the number of conditions to be labelled
                          
                          
                          numericInput("num_conds", 
                                       label = "Conditions",
                                       min = 1,
                                       max = 96,
                                       value = 1),
                          
                          br(),
                          h5(helpText("Changing the number of experimental conditions will erase all designated colors and conditions.")),
                          
                          helpText("control checkbox"),
                          verbatimTextOutput("ctls_checked"),
                          helpText('normalizing control checkbox'),
                          verbatimTextOutput("norm_ctls_checked")
                        ),
                        
                        mainPanel(
                          tags$style('.shiny-options-group{ 
                                        margin-top: 5px !important;}'),
                          
                          column(4, "",
                                 uiOutput("boxes_conds")
                          ), #close condition columns
                          
                          column(4, "",
                                 
                                 uiOutput("control_checkbox"),
                          ),
                          
                          
                        ),
                      ), #close fluidrow
             ), #End panel 3
  ) #close navbarpage
)#close ui, fluidpage


########## Server logic #########

server = function(input, output, session) {

  #### Page 3: Conditions ####
  
  #Number output for number of conditions
  output$value <- renderPrint({ input$num_conds })
  
  #Experimental condition boxes for UI text input
  output$boxes_conds <- renderUI({
    num_conds <- as.integer(input$num_conds)
    
    lapply(1:num_conds, function(i) {
      cond_names <- textInput(paste0("condID", i),
                              label = paste0("Treatment/ Condition ", i),
                              placeholder = "Enter condition...")
    })
  })
  
  output$control_checkbox <- renderUI({
    num_conds <- as.integer(input$num_conds)
    
    lapply(1:num_conds, function(i) {
      div(
        checkboxInput(paste0("CTLcheckbox", i), 
                      label = paste0("Control ", i), 
                      value = FALSE),
        
        checkboxInput(paste0("normCTLcheckbox", i), 
                      label = paste0("Normalizing control ", i), 
                      value = FALSE),
        
        
        style = 'padding-bottom: 7.62px;'

      )
    })
  })
  
  #verification list for the controls, positive/mut or negative/WT
  controls_list <- list()
  
  controls <- reactive({ 
    num_conds <- as.integer(input$num_conds)
    
    lapply(1:num_conds, function(i) { 
      if(input[[paste0('CTLcheckbox', i)]] ==  TRUE) 
        controls_list <- input[[paste0('condID', i)]]
    })
    
  })
  
  controls_coll <- reactive({ strsplit(paste0(unlist(controls(), recursive = FALSE), collapse = ','), ",") })
  
  output$ctls_checked <- renderPrint({ 
    controls_coll()
    
  })
  
  #verification list for the normalized controls list
  normalized_controls_list <- list()
  
  normalized_controls <- reactive({ 
    num_conds <- as.integer(input$num_conds)
    
    lapply(1:num_conds, function(i) {
      
      if(input[[paste0('normCTLcheckbox', i)]] ==  TRUE) 
        controls_list <- input[[paste0('condID', i)]]
    })
  })
  
  normalized_controls_coll <- reactive({ strsplit(paste0(unlist(normalized_controls(), recursive = FALSE), collapse = ','), ",") })
  
  
  output$norm_ctls_checked <- renderPrint({ 
    normalized_controls_coll()
    
  })

  #This is my current attempt at making it so that the normalized_control checkboxes are dependant on the control checkboxes
  observeEvent(input$num_conds, {
    lapply(1:input$num_conds, function(i){
      
      
      observeEvent(input[[paste0('CTLcheckbox', i)]], {
        #This will set the normalized_control checkboxes to FALSE whenever the control checkbox is FALSE
        if (input[[paste0('CTLcheckbox', i)]] == FALSE && input[[paste0('normCTLcheckbox', i)]] == TRUE)
          updateCheckboxInput(session, input[[paste0('normCTLcheckbox', i)]], value = input[[paste0('CTLcheckbox', i)]]) 
      })
      
      observeEvent(input[[paste0('normCTLcheckbox', i)]], {
        #This will update the control checkboxes to TRUE whenever the normalized_control checkbox is TRUE
        if (input[[paste0('CTLcheckbox', i)]] == FALSE && input[[paste0('normCTLcheckbox', i)]] == TRUE)
          updateCheckboxInput(session, input[[paste0('CTLcheckbox', i)]], value = input[[paste0('normCTLcheckbox', i)]]) 
      })
    })
  })
  
  
} # close server

shinyApp(ui = ui, server = server)



mardi 27 juin 2023

Custom checkbox validation error notice issue in Woocommerce registration

In WooCommerce, I am using the following code to add a custom "privacy" checkbox to the customer registration form:

// Addind a checkbox to registration form
add_action( 'woocommerce_register_form', 'add_privacy_checkbox_registration' );
function add_privacy_checkbox_registration() {
    $checkbox_text = sprintf( '%s <a href="%s"><strong>%s</strong></a>', __( 'Я прочитал и согласен с' ), 
    esc_url( site_url('/politic-conf/') ), __( 'политикой конфиденциальности' ) );
    ?>
    <div class="woocommerce-privacy-policy-wrapper">
        <p class="form-row validate-required">
            <label class="woocommerce-form__label woocommerce-form__label-for-checkbox checkbox">
            <input type="checkbox" class="woocommerce-form__input woocommerce-form__input-checkbox input-checkbox" name="privacy_policy" <?php checked( false, true ); ?> id="privacy-policy" />
                <span class="woocommerce-privacy-policy-checkbox-text"><?php echo $checkbox_text; ?></span> <abbr class="required" title="<?php esc_attr_e( 'required', 'woocommerce' ); ?>">*</abbr>
            </label>
            <input type="hidden" name="policy-field" value="1" />
        </p>
    </div>
    <?php
}

// The validation
add_filter( 'woocommerce_registration_errors', 'privacy_checkbox_registration_validation', 10, 3 );
function privacy_checkbox_registration_validation( $errors ) {
 
    if( is_checkout() ) {
        return $errors;
    }
 
    if ( empty( $_POST[ 'privacy_policy' ] ) ) {
        $errors->add( 'privacy_policy_reg_error', 'Вам нужно принять политику конфиденциальности.' );
    }
 
    return $errors;
 
}

The code works. The checkbox has been added. The checkbox logic works. That is, if you do not check the box, there will be no user registration.

But there is a problem. The error text is not displayed on the screen if the checkbox is not clicked...

Here is the page of my site with the problem - page with issue

Any ideas?




How to display data after clicking a checkbox

I am new to ReactJS, I have "providers" data from an API displayed in checkboxes. I want to click on a provider then display products that particular provider has.

Currently I can get data from the API for both the Provider and Products, but when I return the data for the products it brings back everything in the API array however I want products of specific provider.

this is the API: https://apigw.mweb.co.za/prod/baas/proxy/marketing/products/promos/FTTH-WEBCONNECT-M2M,FTTH-CCC-CLARA-CLAWBACK,FTTH-TTCONNECT-CLAWBACK-100MBUP,FTTH-VUMA-SETUP-CLAWBACK-1MONTHFREE,FTTH-EVOTEL-CLAWBACK-100MBUP,FTTH-MFN-CLAWBACK-PROMO4,FTTH-LINKAFRICA-SETUP-CLAWBACK-100MBUP,FTTH-ZOOM-SETUP-CLAWBACK-1MONTHFREE,FTTH-MFN-SETUP-CLAWBACK-1MONTHFREE,FTTH-FROGFOOTAIR-CLAWBACK,FTTH-CCC-ALT-SETUP-100MBUP,FTTH-CLEARACCESS-CLAWBACK,FTTH-VODA-CLAWBACK-100MBUP,FTTH-LINKLAYER-CLAWBACK-100MBUP,FTTH-VUMA-12MONTH-CLAWBACK-25MBPS,FTTH-LIGHTSTRUCK-SETUP-CLAWBACK-100MBUP,FTTH-OCTOTEL-SETUP-CLAWBACK-1MONTHFREE,FTTH-CCC-SETUP-100MBUP,FTTH-FROG-SETUP-CLAWBACK-1MONTHFREE,FTTH-OPEN-SETUP-CLAWBACK-1MONTHFREE?sellable_online=true

** My code currently for retrieving products data currently looks like this:**

CODE

NB: this returns all products in the array but I want to check on "Evotel Provider" and get Evotel Products.

Please help

Screenshot of what I want to achieve




lundi 26 juin 2023

Nebular checkbox is considered checked but doesn't light up

I'm working on an Angular component in which there are Nebular checkboxes.

When I click on any checkbox for the first time, the click event is registered and the action associated to it is performed. However, the checkbox doesn't light up.

Here is the code for the HTML and TS involving this checkbox as well as screenshots of the issue. enter image description here enter image description here

In the first image, I clicked on the checkbox (originally "false" was displayed next to it), and the text became "true" (this is the expected behaviour).

In the second image, you can see the generated HTML with "ng-reflect-checked" set at "true", which is another sign that the checkbox is considered checked.

And now the code for the HTML and relevent fonctions :

<nb-checkbox *ngIf="globalSettings.showMultipleSelection" class="list-checkbox clickable" (click)="toggleSelectedItem(item, $event)"
                             [checked]="itemSelected( item )" ></nb-checkbox>
itemSelected( item ) {
    const key = this.utilsService. getObjectValue( item, this.globalSettings.multipleSelectionKey )
    return (this.selectedItems.findIndex( ( elem ) => elem === key ) >= 0)
  }

toggleSelectedItem(item, $event ) {
    const key = this.utilsService.getObjectValue( item, this.globalSettings.multipleSelectionKey )
    const tmpIndex = this.selectedItems.findIndex( ( elem ) => elem === key )
    $event.stopPropagation()
    if ( tmpIndex >= 0 ) {
      this.selectedItems.splice( tmpIndex, 1 )
      this.emitSelectedItems( 'remove', [ key ]  )

    } else {
      this.selectedItems.push( key )
      this.emitSelectedItems( 'add', [ key ]  )

    }
    this.selectedItems = JSON.parse( JSON.stringify( this.selectedItems ) )
    this.onSelectedItemChange()
  }

In our case, the itemSelected function sends true when the item is in an array called "selectedItems" and false otherwise. toggleSelectedItem adds or removes the item from the array.

Once again, the code does work properly and has the expected behaviour, and the only issue is the checkbox that doesn't light up.

I've checked if there was any CSS that conflicted with my checkbox, but there wasn't. I also removed the (onRowClick) to see if it wasn't an event order issue, and it still didn't light up. I've also tried tinkering with the TS and HTML, but nothing worked.

Thanks in advance for your help !




vendredi 23 juin 2023

How can I count every next each other checked checkbox in excel?

I'm looking for more then 8h, unsuccessfully. Here is my problem: I would like to count checked checkbox in excel with pause... so count every next each other checked box. For example how many checked checkbox is in group A, and B and .... but group A and B is in the same row (but separated) (it's possible to one row, 19, will fully with checked checkbox). I see the =COUNTIF and another formula can count all in one... but not with separate. Can you offer and help me?

enter image description here

I try wto solve this problem with IF COUNTIF COUNTIFS excel's forms but I can't fixed it.




How can I make a checkbox slide back to its position after unchecking it?

I am making a Checkbox Toggle Slider for a website and I got the checkbox to slide when its checked but I cant figure out how to make it smoothly slide back to its original position. Any help would be much appreciated!!

#spherewishlist
{
    height:40px;
    width:70px;
    background-color:gray;
    border-radius:40px;
    display: block;
    border-color: white;
}
#circlewishlist
{
    height:36px;
    width:40px;
    background-color:white;
    border-radius:100%;
    display: block;
    box-shadow: 0px 1px 1px  #141414;
    position:relative;
margin-left:3px;
    content:url('white-circle-frame-with-shadow-free-png.png');
        appearance:none;
top:41px;
}

#circlewishlist:checked
{   animation-name:slidewish;
    animation-duration: 1s;  
    right:-24px;
}
#circlewishlist:checked + #spherewishlist
{background-color:green;}
@keyframes slidewish
{    0%{left:0px;}
    100%{left:24px;}
}

this is the html

<div>
    <input id="circlewishlist" type="checkbox"><!-- this is the circle-->
    <div id="spherewishlist"></div><!-- this is the sphere-->
   </div>



mercredi 21 juin 2023

Updating checkbox's checked status from parent - Angular

I'm trying to create a reusable switcher component whose state won't be changed immediately when clicked, but after an API call is made in parent component - if there is no error, the state will be changed, while when there is an error, the state will remain unchanged.

The problem occurs when the checkbox state is updated from the parent level, the @Input value is updated correctly, but the checkbox state remains unchanged.

Simple reproduction of the problem at the link below: stackblitz-checkbox-issue

I tried to use ChangeDetectorRef after updating the @Input value, ngModel bindinig, but to no avail.

Any ideas what to do to update the checkbox state from the parent level to work properly?




lundi 19 juin 2023

How do I require at least one checkbox to be selected?

Part of my HTML form looks like this:

<p>Please select your preferred time slot:</p>
<input type="checkbox" id="am" name="am" value="AM">
<label for="am">AM (09:00-13:00)</label><br>
<input type="checkbox" id="pm" name="pm" value="PM">
<label for="pm">PM (13:00-18:00)</label><br>

I'd like for at least one of the checkboxes to be selected as a requirement of the form being submitted. At the moment, if I leave both unselected, the form is still submitted.

I considered using the required property but I can't figure out how to utilise it without making both required.




dimanche 18 juin 2023

How to send id of a checked checkboxes which contains categories to ajax and show subcategories related to that checked checkbox?

I am successfully send checkbox value which is id of a category when checkbox is checked and show subcategories on thee same page related to selected subcategory but I have a problem when click on multiple categories and again unchecked one of the category all subcategories goes un display. I want to un display the subcategory of only unchecked category when I check and uncheck the values anytime. here is my code hope you get my point thank you

**Ajax **

<script>
function showUser(str) {
  if (str == "") {
    document.getElementById("txtHint").innerHTML = "";
    return;
  } else {
    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = function() {
      if (this.readyState == 4 && this.status == 200) {

        document.getElementById("txtHint").innerHTML += this.responseText;
    
      }
    };

    
    xmlhttp.open("POST","getsubcat.php?q="+str,true);
    xmlhttp.send();
    
  }
}
</script>

J query

 <script>
         
          $(function() {
    //code here
    $('input[type=checkbox]').on('change', function() {
    if($(this).is(':checked')) {
        showUser($(this).val());
    }
    
    
    else{
        
        showUser("");
    }
});
          
         
});
          
      </script>

category checkboxes

  <?php
          
          
            foreach($cat as $row)
            {
                
            ?> 
           <input class = "messageCheckbox" type = "checkbox" id = "check" value = "<?php echo $row["id"]; ?>">
           <label for = "check"><?php echo $row["name"]; ?></label>
           
           
           <?php
            }
           ?>
    
    <br>
    
    <div id="txtHint"><b></b></div>

getsubcat.php

<?php
$q = intval($_GET['q']);


$result = $link->query("SELECT *
FROM subcat WHERE cat_id = '".$q."'");

?>
<div class = "checkbox">
    
<?php
while($row = mysqli_fetch_array($result)) {
    
?>

<input type="checkbox" id="sub_cat" name="sub_cat" value="<?php echo $row['subcat']; ?>">
<label for="sub_cat"> <?php echo $row['subcat'];  ?></label><br>

<?php 
}


?>

I am trying to solve with j query code attached but when I checked checkbox it displayed the subcategories of all checked checkboxes but when un check any of the box this will un display all the subcategories




How can i implement a checkbox in v-data-table header for vuetify 3?

When i try to customize my data table header using v-slot:headers select-all checkbox disappears. I guess i need to re implement it by myself. There are a lots of example for Vuetify 2 in the net but there isn't any for Vuetify 3 version.

Default checkbox disappears

Here is my code.

<v-data-table
      :show-select="true"
      v-model="selected"
      :headers="headers"
      :items="items"
    >
      <template v-slot:headers="{ columns, isSorted, getSortIcon, toggleSort }">
        <tr>
          <template v-for="column in columns" :key="column.key">
            <th v-if="column.key != 'data-table-group'">
              <span v-if="colum.key == 'data-table-select'">
                <v-checkbox></checkbox>
              </span>
              <span v-else class="ml-2"></span>
            </th>
          </template>
        </tr>
      </template>
</v-data-table>

so how can I make a checkbox which is working like default select-all function for vuetify 3 ?




vendredi 16 juin 2023

Why doesn't the tick appear in my custom checkbox

Can anyone explain why the tick does not appear when I check my custom checkbox and help me fix the issue? I attempted to replicate the example from W3Schools and here is my code:

<div class="bottom">
  <div class="left">
    <div class="checkbox" style="margin-right: 3px;">
      <input type="checkbox">
    </div>
    <span>Remember me</span>
  </div>
  <span>Need help?</span>
</div>

Here is the CSS style for the code above:

.bottom {
  display: flex;
  justify-content: space-between;
  width: 300px;
}

.left {
  display: flex;
  flex-direction: row;
  position: relative;
}

/* Hide the actual checkbox */
input[type=checkbox] {
  opacity: 0;
  margin-right: 4px;
}

/* Create a custom checkbox*/
.checkbox::before {
  content: "";
  border: none;
  border-radius: 2px;
  height: 16px;
  width: 16px;
  position: absolute;
  background-color: #737373;
}

.checkbox::after {
  content: "";
  border: 3px solid;
  border-top: 0;
  border-left: 0;
  width: 4px;
  height: 9px;
  position: absolute;
  top: 1px;
  left: 5px;
  transform: rotate(45deg);
  opacity: 0;
  transition: opacity 10ms;
}

.checkbox input:checked ~ .checkbox::after {
  opacity: 1;
}

Thanks in advance!




How do i select items in a gallery usign checkboxes

i'm having problems with a gallery in powerapps, i'm trying to select multiple items in the gallery using checkboxes, now i can select just one item from the gallery, i've tried a couple of things an nothing seems to work. I need to select more tahn one so i can print multiple items in PDF.

enter image description here

I tried with Updates, ForAll, Patch, both in on check and on select but nothing seems to work, everything keeps giving errors.




jeudi 15 juin 2023

WPF treeview checkboxes how to check all children when parent is checked

Yes, i know its been asked a bazillion times, I've looked through, and tried most of those answers. for context, I'm creating a dock-able pane within an API (Revit). Most solutions are based on the Windows class, but I'm forced to use a Page class for the form. My data is gathered from two lists parsed through a custom class and sorted into one list, then i had the brilliant idea of mapping it to a dictionary, with one of the list properties as its key. Displaying the dictionary in a treeview was nice an easy, but as you can see checking the Parent does not check all its children: Populated TreeView

So id like to keep the dictionary if possible, but am fully prepared to restructure my list as needed to get this working. To summarize the ask:

  • Keep the data structured as as a Dictionory if possible.
  • Be able to check all children when parent is checked, but parent should not be checked (i do not require a three state) when children are checked.
  • Checkbox and item are separate controls, such that user can select an item, which will display and image without checking the checkbox.

What i've tried; recursive functions and Revit do not mix, so mapping my list to the treeview that way is out. Binding the IsChecked of the child to the parent and vice versa. I think this fails due to the way the xaml is structured to use the dictionary. And a slew of other things i cant think of right now.

Anyways, heres the XAML:

<Page x:Class="Typ_Detail_Selector.TypDetForm"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             mc:Ignorable="d" 
             Title="Typical Detail Selector" Foreground="{x:Null}" MinWidth="100" MinHeight="400" Background="{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}">
    <StackPanel HorizontalAlignment="Stretch" Margin="5,5,5,5" VerticalAlignment="Stretch">
        <Label Content="Views" HorizontalAlignment="Left" Margin="0,0,0,0" VerticalAlignment="Top"/>
        <TreeView x:Name="TreeViewDets" HorizontalAlignment="Left" Height="400" MinWidth="400" SelectedItemChanged="TreeViewDets_SelectedItemChanged">
            <TreeView.ItemTemplate>
                <HierarchicalDataTemplate ItemsSource="{Binding Value}">
                    <StackPanel Orientation="Horizontal">
                        <CheckBox Focusable="False" IsChecked="{Binding Checked}" Click="CheckPleaseParent"/>
                        <TextBlock Text="{Binding Key}"/>
                    </StackPanel>
                    <HierarchicalDataTemplate.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal">
                                <CheckBox Focusable="False" IsChecked="{Binding Checked}" Click="CheckPleaseChild"/>
                                <TextBlock Text="{Binding Name}"/>
                            </StackPanel>
                        </DataTemplate>
                    </HierarchicalDataTemplate.ItemTemplate>
                    <HierarchicalDataTemplate.ItemContainerStyle>
                        <Style TargetType = "TreeViewItem">
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding Path=Loaded}" Value="true">
                                    <Setter Property="Focusable" Value="False"/>
                                    <Setter Property="Foreground" Value="DimGray"/>
                                </DataTrigger>
                                <MultiDataTrigger>
                                    <MultiDataTrigger.Conditions>
                                        <Condition Binding="{Binding Path=Loaded}" Value="false"/>
                                        <Condition Binding="{Binding Path=Checked}" Value="true"/>
                                    </MultiDataTrigger.Conditions>
                                    <Setter Property="Background" Value="SteelBlue"/>
                                    <Setter Property="Foreground" Value="Azure"/>
                                </MultiDataTrigger>
                            </Style.Triggers>
                        </Style>
                    </HierarchicalDataTemplate.ItemContainerStyle>
                    <HierarchicalDataTemplate.Resources>
                        <Style TargetType="{x:Type CheckBox}">
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding Path=Loaded}" Value="true">
                                    <Setter Property="IsEnabled" Value="False"/>
                                    <Setter Property="Foreground" Value="DimGray"/>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </HierarchicalDataTemplate.Resources>
                </HierarchicalDataTemplate>
            </TreeView.ItemTemplate>
        </TreeView>
        <Grid>
            <Button x:Name="RunButton" Content="Insert Views" HorizontalAlignment="Right"  VerticalAlignment="Bottom" Width="180" Height="25" Click="Run_Click"/>
        </Grid>
    </StackPanel>
</Page>

And the xaml.cs, i must stress this is for API work, so theres a lot of extra things not specific to the WPF itself:

using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Media.Imaging;
using System.Windows.Controls;
using Autodesk.Revit.UI;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Events;
using View = Autodesk.Revit.DB.View;
using Application = Autodesk.Revit.ApplicationServices.Application;
using Transform = Autodesk.Revit.DB.Transform;
using System.Reflection;
using System.Collections;

namespace Typ_Detail_Selector
{
    public partial class TypDetForm : Page, IDockablePaneProvider
    {
        private TypDetailRegister TypDetViews;
        public Document TypDoc;
        private Document ThisDoc;
        private Application App;
        private UIApplication UiApp;
        private Dictionary<string, List<ViewProperties>> viewDict = new Dictionary<string, List<ViewProperties>>();

        public TypDetForm()
        {
            InitializeComponent();
        }
        public void SetupDockablePane(DockablePaneProviderData data)
        {
            data.FrameworkElement = this;
            data.InitialState = new DockablePaneState();
            data.InitialState.DockPosition = DockPosition.Right;
        }
        public void ReferenceItems(TypDetailRegister _typdetviews, Document _typdoc, Document _thisdoc, Application _app)
        {   //this is to set references to things from command class
            TypDoc = _typdoc;
            ThisDoc = _thisdoc;
            TypDetViews = _typdetviews;
            App = _app;
            UiApp = new UIApplication(App);
            UiApp.Idling += TypDetViews.TwiddleThumbs;
            viewDict = TypDetViews.ViewList().GroupBy(x => x.SheetName).ToDictionary(x => x.Key, x => x.ToList());
            RefreshCompare();
        }
        public void RefreshCompare()
        {//compares list of views an schedules in the current project to the typ det file,
         //flags them as "loaded" so you cant re import them later.
            List<ViewProperties> _tempviewprops = TypDetViews.ViewList();
            List<Element> _compareViewList = new FilteredElementCollector(ThisDoc).OfClass(typeof(ViewDrafting))
                .Where(v => v.Name != "MKA Starting View").ToList();
            List<Element> _compareSchedList = new FilteredElementCollector(ThisDoc).OfClass(typeof(ViewSchedule))
                .Where(s => !s.Name.ToUpper().Contains("REVISION"))
                .Where(s => !s.Name.Contains("DRAWING LIST"))
                .ToList();
            _compareViewList.AddRange(_compareSchedList);
            foreach (ViewProperties v in TypDetViews.ViewList())
            {
                var _viewExists = from views in _compareViewList
                                  where v.Name == views.Name
                                  select v;
                if (_viewExists.Any())
                {
                    v.Loaded = true;
                    v.Checked = true;
                }
                else
                {
                    v.Loaded = false;
                    v.Checked = false;
                }
            }

            TreeViewDets.ItemsSource = null;
            TreeViewDets.ItemsSource = viewDict;
        }
      
        private void ListViewDets_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {   //handler for when user selects (but not checks!) and item in teh list
            string imagelibrary = @"K:\Development\_Typical Detail Change Tracking\Base Models\Typ Images";
            if (e.AddedItems.Count > 0) //check if something was in fact selected
            {
                //dim teh item as a member of the list class to get at certain properites
                ViewProperties test = e.AddedItems[0] as ViewProperties;
                try
                {
                    //replace characters that windows automatically replaces for the png files
                    string view_image = imagelibrary + "\\" + test.Name.Replace("\"", "-").Replace("/", "-") + ".png";
                    if (File.Exists(view_image))//if an image file exists in teh library
                    { //add it to to image control on the form as preview.
                        BitmapImage bmp = new BitmapImage(new Uri(view_image, UriKind.Absolute));
                        // PreviewImage.Source = bmp;
                    }
                }
                catch { }
                e.AddedItems.Clear();//clear it so program does not get confused the next time handler is triggered.
            }
        }

        private void CheckPleaseChild(object sender, RoutedEventArgs e)
        { //seperate handler to change the checkbox, and ping the selection changed event
            var cb = sender as CheckBox;
            var item = cb.DataContext;
            ListViewDets.SelectedItem = item;
        }
        private void CheckPleaseParent(object sender, RoutedEventArgs e)
        { //seperate handler to change the checkbox, and ping the selection changed event
            var cb = sender as CheckBox;
            var iteam = cb.DataContext;
            PropertyInfo[] testprops = cb.DataContext.GetType().GetProperties();
            List<ViewProperties> testlist = new List<ViewProperties>();
            testlist = (List<ViewProperties>)testprops.Last().GetValue(cb.DataContext, null);
            foreach (var temp in testlist)
            {
                //need to trigger checkpleasechild somehow?

            }

        }
        private void TreeViewDets_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
        {
            TreeView tv = sender as TreeView;
            var item = tv.Items.CurrentItem; //this gets me the KVP, same as in checkpleaseparent
        }
        private void ListViewDets_SizeChanged(object sender, SizeChangedEventArgs e)
        {   //this is to stretch the listview with the form
            ListView tempview = sender as ListView;
            GridView gview = tempview.View as GridView;
            var defaultwidth = tempview.ActualWidth - SystemParameters.VerticalScrollBarWidth;
            var percent = 0.95;
            gview.Columns[1].Width = defaultwidth * percent;
        }
        private void Run_Click(object sender, RoutedEventArgs e)
        {   //clicking run, sets the bool, which in trun runs the InsertViews when able (idling)
            GlobalVars.DoTheThings = true;
        }
        public void InsertViews(ExternalCommandData commdata)
        {
            GlobalVars.DoTheThings = false;//reset bool
            App.FailuresProcessing += HideDupeMessages;//to deal with dupilcate names dialog
            ExternalCommandData _commdata = commdata;
            //grab all the element ids of items that are checked in the list, but not loaded, which are the views we want to insert
            ICollection<ElementId> _viewIds = TypDetViews.ViewList().Where(x => x.Checked && !x.Loaded).Select(y => y.ViewId).ToList();
            ICollection<ElementId> _copiedViewIds = null;
            Document _doc = _commdata.Application.ActiveUIDocument.Document;
            ThisDoc = _doc;
            using (TransactionGroup tg = new TransactionGroup(_doc)) //trans group to keep the undo list clean
            {
                tg.Start();
                using (Transaction trView = new Transaction(_doc))
                {
                    foreach (ElementId _viewId in _viewIds)
                    {
                        ICollection<ElementId> _vId = _viewIds.Where(x => x == _viewId).ToList(); //annoying API thing, must put the element id in an Icollection, else it doesn work
                        bool test = TypDetViews.ViewList().Where(x => x.ViewId == _vId.First()).Select(y => y.SchedTest).First();//is it a scehdule?
                        trView.Start("Copy Typ Views to Project");
                        {
                            CopyPasteOptions opts = new CopyPasteOptions();
                            opts.SetDuplicateTypeNamesHandler(new DupeNamesHandler());
                            try
                            {   //add the elementid of the view or sched that was just inserted to a empty collection
                                _copiedViewIds = ElementTransformUtils.CopyElements(TypDoc, _vId, _doc, Transform.Identity, opts);
                            }
                            catch { }
                            trView.Commit();
                        }
                        //if its not a sched, grab every element in teh view,
                        //bypass for scheds, as it grabs the modeled elements in the sched(errors out for stickies)
                        if (test)
                        {
                            ICollection<ElementId> _nestedEelemIds = new FilteredElementCollector(TypDoc, _viewId)
                                .WherePasses(new ElementCategoryFilter(ElementId.InvalidElementId, true))
                                .ToElementIds();
                            //if we foudn elements, copy them from the typ view to the new view we just inserted
                            if (_nestedEelemIds.Count > 0)
                            {
                                View _sourceView = TypDoc.GetElement(_viewId) as View;
                                View _targetView = _doc.GetElement(_copiedViewIds.First()) as View;
                                using (Transaction trElements = new Transaction(_doc))
                                {
                                    trElements.Start("Copy Typ Det Elements to Project View");
                                    CopyPasteOptions opts = new CopyPasteOptions();
                                    opts.SetDuplicateTypeNamesHandler(new DupeNamesHandler());
                                    ElementTransformUtils.CopyElements(_sourceView, _nestedEelemIds, _targetView, Transform.Identity, opts);
                                    trElements.Commit();
                                }
                            }
                        }
                        _copiedViewIds.Clear();//clear teh list for the next run.
                    }
                }
                tg.Assimilate();
            }

            //write to a text file
            try
            {
                string log_file = "Typical Detail Selector.txt";
                string text = "";
                string date = DateTime.Now.Year.ToString() + "." + DateTime.Now.Month.ToString() + "." + DateTime.Now.Day.ToString();
                string user = Environment.UserName;
                string other = "Run";
                text = date + " ~ " + user + " ~ " + other;
                StreamWriter sw = File.AppendText("J:/CADD/Customization/Add-In Usage/" + log_file);
                sw.WriteLine(text);
                sw.Close();
            }
            catch
            {

            }
            RefreshCompare();//refresh the lsit when we done inserting views.
        }
        public void SetActiveDocument()
        {
            ThisDoc = UiApp.ActiveUIDocument.Document;
            RefreshCompare();
        }
        public void NewDocCity(object sender, DocumentOpenedEventArgs e)
        {
            SetActiveDocument();
        }
       
        //public PreviewControl PrevCon { get; set; }
        private void HideDupeMessages(object sender, FailuresProcessingEventArgs e)
        {
            FailuresAccessor FA = e.GetFailuresAccessor();
            foreach (FailureMessageAccessor fmsg in FA.GetFailureMessages())
            {
                if (fmsg.GetSeverity() == FailureSeverity.Warning)
                {
                    FA.DeleteWarning(fmsg);
                    e.SetProcessingResult(FailureProcessingResult.ProceedWithCommit);
                }
            }
            e.SetProcessingResult(FailureProcessingResult.Continue);
        }
    }
    public class DupeNamesHandler : IDuplicateTypeNamesHandler
    {
        public DuplicateTypeAction OnDuplicateTypeNamesFound(DuplicateTypeNamesHandlerArgs args)
        {
            return DuplicateTypeAction.UseDestinationTypes;
        }
    }
}



CheckBox within CheckBox - R-Shiny

I have a bunch of checkboxGroupInput within my ui mainPanel like so

ui <- fluidPage(
    mainPanel = mainPanel(
        tabPanel(
    
            checkboxGroupInput("ID1", "Name1", choiceNames = list$a, choiceValues = list$b),
            uiOutput("conditionalInput_ID1"),
            
            checkboxGroupInput("ID2", "Name2", choiceNames = list$a, choiceValues = list$b),
            uiOutput("conditionalInput_ID2"),
            
            checkboxGroupInput("ID3", "Name3", choiceNames = list$a, choiceValues = list$b),
            uiOutput("conditionalInput_ID3")
    
        )
    )
)

The output within the server fct looks like so

  output$conditionalInput_ID1<- renderUI({
    if(!is.null(input$ID1)){
      if(any(input$ID1== "other")){
        textInput("ID1_other", "")
        }}
    })

  output$conditionalInput_ID2<- renderUI({
    if(!is.null(input$ID1)){
      if(any(input$ID12== "other")){
        textInput("ID2_other", "")
        }}
    })

  output$conditionalInput_ID3<- renderUI({
    if(!is.null(input$ID3)){
      if(any(input$ID3== "other")){
        textInput("ID3_other", "")
        }}
    })
  

ID1 - ID3 consists of a bunch of otption incl the option "other" with an additional textInput by choosing "other".

The reason for my question is, in ID1 are checkBoxes (lets call them ID1_a and ID1_b) for which i want ID2 to appear if ID1_a is choosen and ID3 to appear if ID1_b is chossen.

So basicly conditional checkboxes within checkboxes. Any ideas? Thx in advance!




mercredi 14 juin 2023

How can I give check box in gridview a value that is not from the data source?

I have this gridview on an aspx page (Web form):

<asp:GridView ID="GridView" runat="server" showheader=false BorderStyle="None"CellPadding="4" GridLines="Horizontal" AutoGenerateColumns="false" AllowPaging="true" CssClass="wrapper5">
                        <Columns>
                            <asp:TemplateField>
                                <ItemTemplate>
                                    <asp:CheckBox ID="CheckBoxFR" runat="server"/>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField>
                                <ItemTemplate>
                                    <asp:Label ID="itemName" Text='<% # Eval("itemName") %>' runat="server"></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField>
                                <ItemTemplate>
                                    <asp:Label ID="itemId" Text='<% #Eval("itemId") %>' runat="server" Visible="false"></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                        </asp:GridView>

I have an array of itemIds that the user has. I want that the checkboxes in the same row as the itemIds will be checkd if the itemId is in the array.

This is what I tried in the code behind in c#:

public localhost.WebService1 w = new localhost.WebService1();
        public localhost.Item i = new localhost.Item();
        public localhost.MyUser u = new localhost.MyUser();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                int[] ei = w.SelectListOfUsersItemsIDS(1); //user number 1
                this.GridViewVG.DataSource = w.SelectListOfItems();
                this.GridViewVG.DataBind();
                for (int i = 0; i < ei.Length; i++)
                {
                    int item = ei[i];
                    foreach (GridViewRow row in GridView.Rows)
                    {
                        Label l = (Label)row.FindControl("itemId");
                        if (l.Text != null)
                        {
                            int itemId = Convert.ToInt32(l.Text);
                            if (itemId == item)
                            {
                                CheckBox checkbox = (CheckBox)row.FindControl("CheckBoxFR") as CheckBox;
                                checkbox.Checked = true;
                            }
                        }
                    }
                }

I also tried using private bool active; and changing it to true when checking if (itemId == item) and it didn't work.

How can I do this?




How can I check a checkbox in gridview based on a condition?

I have gridview on an aspx page (web form) with a check box and Id (the Id's are from a table of Id's). In the code behind the page (c#), I get a list of Id's. I want that all of the check boxes that are next to an Id that is on the list to be checked.

I tried this:

public localhost.WebService1 w = new localhost.WebService1();
public localhost.User u = new localhost.User();

if (!IsPostBack)
            {
                this.GridView.DataSource = w.SelectListOfIds();
                this.GridView.DataBind();
                int[] ei = w.SelectListOfIDSOfUser(u.UserId);
                for (int i = 0; i < ei.Length; i++)
                {
                    int id = ei[i];
                    foreach (GridViewRow row in GridView.Rows)
                    {
                        Label l = (Label)row.FindControl("Id");
                        if (l.Text != null)
                        {
                            int cId = Convert.ToInt32(l.Text);
                            if (cId == id)
                            {
                                CheckBox checkbox = (CheckBox)row.FindControl("CheckBox1") as CheckBox;
                                checkbox.Checked = true;
                            }
                        }
                    }
                 }
             }

This is my gridview:

<asp:GridView ID="GridView" showheader=false runat="server" BorderWidth="1px" CellPadding="4" ForeColor="Black" GridLines="Horizontal" AutoGenerateColumns="false" AllowPaging="true" CssClass="wrapper5">

                       <Columns>
                           <asp:TemplateField>
                               <ItemTemplate>
                                   <asp:CheckBox ID="CheckBox1" runat="server"/>
                               </ItemTemplate>
                           </asp:TemplateField>
                           <asp:TemplateField>
                               <ItemTemplate>
                                   <asp:Label ID="Id" Text='<% #Eval("id") %>' runat="server"></asp:Label>
                               </ItemTemplate>
                           </asp:TemplateField>
                       </Columns>
                       </asp:GridView>

I get the error: reference to an object not set to an object instance on checkbox.Checked = true;. Is there a way to do this?




mardi 13 juin 2023

How can I change the state of checkboxs from a gridview in c#?

I have a gridview on an aspx page (WebForm) that has item name and checkbox. In the code behind in c#, I get a list of items names and I want that the checkboxes next to the items I already have will be checked.

I know to find the checkbox using (CheckBox)row.FindControl("CheckBox1"), but the Checked method doesn't work on it. Is there a way to do this?




Trying to print only radio button’s data from cookie in which selected data stored But it’s printing both checkbox and radio button’s stored data

We have checkboxes and radio button in our product page as data , we are store selected data in cookie and when user click on continue button page will redirect to cart page , on cart page we are printing selected stored data in card but when we only want radio button’s stored selected data to be print but using my code it’s printing both checkbox and radio button’s selected data.

here is full code of our cart page ,

prepare("SELECT sub_name, sem_name, price FROM selected_bcom_values"); $stmt->execute(); $selectedData = $stmt->fetchAll(); ?>

<!doctype html>

Include your stylesheets and scripts here --> .card { background-color: white; width: auto; height: auto; border: 0px; border-radius: 30px; padding: 20px; padding-left: 0px; box-shadow: 0 8px 30px -7px #c9dff0; margin: 20px; text-align: left; /* Align cards to the left */ font-family: 'Ubuntu', sans-serif; font-size: 1rem; font-weight: 500; line-height: 1.3; position: relative; }

    .container {

display: flex; flex-direction: row; justify-content: space-between; /* Align cards and order summary / align-items: flex-start; / Align cards to the left */ }

    .col-md-7 {

flex: 0 0 auto; /* Prevent cards from growing to fill the space */ }

    .order-summary {

flex: 0 0 auto; /* Prevent order summary from growing to fill the space / padding-top: 100px; / Add top padding */ }

</style>



<div class="container">

    <div class="col-md-7">


        <br>
        <br>
        <br>
        <?php

Check if the selected data cookie exists if (isset($_COOKIE['selectedData'])) { Retrieve the selected data from the cookie $selectedData = json_decode($_COOKIE['selectedData'], true);

Display the selected data echo "

";

Flag to track if the "Remove" line card has been printed $removeLinePrinted = false;

Counter for the selected checkboxes $selectedCount = 0;

Loop through the selected data and display each item in a card format foreach ($selectedData as $sub_name => $data) { Print the "Remove" line card only once at the top if (!$removeLinePrinted) { echo ""; echo ""; echo " "; echo " "; echo " <label class='form-check-label' style='font-size: .77rem;font-family: 'Varela Round', serif;font-weight:bold;'>$selectedCount/ ITEMS SELECTED"; echo " "; echo " <div id='remove-all-item' style='cursor: pointer;font-family: 'Varela Round', serif;font-weight:bold;'>REMOVE"; echo ""; echo "";

                        $removeLinePrinted = true;
                    }

Open the card div for the current item echo "";

Print the rest of the card content for the current item

echo ""; echo " "; echo " "; echo " "; echo " "; echo ""; echo "

" . str_replace('_', ' ', $sub_name) . "
";

Check if the $data variable is an array if (is_array($data)) { foreach ($data as $material_name => $attempts) { echo "

" . str_replace('_', ' ', $material_name) . "
";

Check if the $attempts variable is an array if (is_array($attempts)) { Find the radio button selection $radioSelection = null; foreach ($attempts as $attempt_name => $price) { if (strpos($attempt_name, 'radio_') !== false) { $radioSelection = $attempt_name; break; } }

Display the radio button selection, if found if ($radioSelection !== null) { $price = str_replace('', ' ', $attempts[$radioSelection]); $firstPart = substr($price, 0, 3); $secondPart = substr($price, 3); echo "Selected Attempt Name: " . str_replace('', ' ', $radioSelection) . "

"; echo "Selected Attempt Price: $firstPart
$secondPart"; } else { If $attempts is not an array, assume it's the price and display it $price = str_replace('_', ' ', $attempts); $firstPart = substr($price, 0, 3); $secondPart = substr($price, 3, -5); echo "

" . $secondPart . "₹ " . $firstPart . "

";
                                //echo "<h5 class='price'> <span style='text-align: right;'>₹ $firstPart</span><br><span>$secondPart</span></h5>";
                            }
                        }

else { If $data is not an array, assume it's the price and display it $price = str_replace('_', ' ', $data); $firstPart = substr($price, 0, 3); $secondPart = substr($price, 3); echo "₹ $firstPart

"; // Display $firstPart on the right side echo " ₹ $firstPart
$secondPart"; } echo ""; echo " '>"; echo "";

Close the card div for the current item echo ""; }

else { echo "

No data selected.

"; } ?>
    <div class="order-summary">
        <div style="border: 1px solid #dcdcdc;padding: 1rem 1rem;background-color: #FFF;">
            <div style="font-family: 'Ubuntu', serif;">
                <h3 style="font-weight:200;">Order Summary</h3>
                <span style="display:none;float: right;"><b>₹ <span id="total_price"></span></b></span>
                <hr style="background-color: #babfbb;">
                <h6 style="text-align: left;">
                    <div class="form-check" style="font-size:1.05rem;display:inline-block;">
                        <label class="form-check-label h-100 align-middle" for="physical_notes">Printable PDFs &nbsp;</label>
                    </div>
                    <!-- <b>₹ <span style="float: right;"><span id="total_price2"></span></span></b> -->
                    <span style="float: right;"> <b>₹ <span id="total_price2"><?php echo $_COOKIE['total_price']; ?></span></b></span>
                </h6>
                <div class=" d-md-block">
                    <hr style="background-color: #babfbb;">
                        <!-- <h6 style="text-align: left;">
                            <div class="form-check" style="font-size:1.05rem;display:inline-block;">
                                <label class="form-check-label h-100 align-middle" for="physical_notes">Total Price &nbsp;</label>
                            </div>
                             <b>₹ <span style="float: right;"><span id="total_price2"></span></span></b> 
                            <span style="float: right;"> <b>₹ <span id="total_price2"><//?php echo $_COOKIE['total_price']; ?></span></b></span>
                        </h6> -->

                    <button class="btn btn-danger" style="background-color: #f05969;color: #fff;width:100%;border-color:#f05969;" id="continue">CONTINUE</button>
                </div>
            </div>
        </div>
    </div>
</div>

Include your scripts here --> Get all the purchase checkboxes const purchCheckboxes = document.querySelectorAll('.purch-checkbox');

Get the total_selected_item element const totalSelectedElement = document.getElementById('total_selected_item');

Update the selected count when a checkbox is checked or unchecked function updateSelectedCount() { const selectedCount = Array.from(purchCheckboxes).filter(checkbox => checkbox.checked).length; totalSelectedElement.textContent = selectedCount; }

Add event listeners to the checkboxes purchCheckboxes.forEach(checkbox => { checkbox.addEventListener('change', updateSelectedCount); });




lundi 12 juin 2023

Using a check box to determine the value of a textbox

I am trying to figure out how to use a check box to determine the value of a textbox.

If the check box is yes I wish a text box to display the contents of another check box (unbound, on different tab in the same form), if it's not I want it to default value.




Updating default html checkbox styles?

I am facing a problem I am trying to figure out how can I update my html checkbox in such a ways that once it is checked instead of tick ✔️ inside I place a small white squared div with lesser dimensions as shown in the attached picture. when I un-check it just a normal black background checkbox with white-border.

enter image description here

I placed some efforts here

=> https://jsbin.com/xejupuziqi/edit?html,css,output,

but out of luck, unfortunately.




What is the difference in the operation of JS functions with checkboxes in HTML?

I'm trying to figure out how to work with a checkbox using JS.

Why does setAttribute("disabled", "") work only when I click checkbox class`s "ch2"?

HTML:

<input type="checkbox" class="ch1" name="ch1" onclick="fn_for_two_chb()">
<label for="ch1">ch1</label>
<input type="checkbox" class="ch2" name="ch2" onclick="fn_for_two_chb()">
<label for="ch2">ch2</label>

JS:

const chb_1 = document.querySelector('.ch1')
const chb_2 = document.querySelector('.ch2')

function fn_for_two_chb() {
    if (chb_1.checked == true) {
            chb_2.setAttribute("disabled", "");
    } else {
            chb_1.removeAttribute("disabled", "");
            chb_2.removeAttribute("disabled", "");
    }

    if (chb_2.checked == true) {
            chb_1.setAttribute("disabled", "");
    } else{
            chb_1.removeAttribute("disabled", "");
            chb_2.removeAttribute("disabled", "");
    }
  }

But when I split this into two functions and assign them to different checkboxes in HTML, it works.

HTML:

<input type="checkbox" class="ch1" name="ch1" onclick="fn_chb_1()">
<label for="ch1">ch1</label>
<input type="checkbox" class="ch2" name="ch2" onclick="fn_chb_2()">
<label for="ch2">ch2</label>

JS:

function fn_chb_1() {

    if (chb_1.checked == true) {
            chb_2.setAttribute("disabled", "");
    } else {
            chb_1.removeAttribute("disabled", "");
            chb_2.removeAttribute("disabled", "");
    }
  }

function fn_chb_2() {

    if (chb_2.checked == true) {
            chb_1.setAttribute("disabled", "");
    } else {
            chb_1.removeAttribute("disabled", "");
            chb_2.removeAttribute("disabled", "");
    }
  }



dimanche 11 juin 2023

How to select all checkboxes at the same column , Asp.net core 5 mvc

I am working on Asp.net core 5 mvc app, And I have a for loop that creates cards, and inside each card, there is a checkbox, Each row has 4 cards, which means that we have 4 columns. I want to add a checkbox above each column to select all checkboxes on the same column, Considering that all cards are created automatically inside a for loop.

And this is my code :

   <form asp-action="ManagePermissions" method="post">
                <input type="hidden" asp-for="RoleId" />
                <div class="col-lg-12">
                    <div class="row">

                        <div class="col-lg-12">
                            <div class="row">
                                @for (int i = 0; i < Model.RoleCalims.Count; i++)
                                {
                                    <div class="col-lg-3">
                                        <div class="card card-body">
                                            <div class="media">
                                                <div class="form-check form-check-inline">
                                                    <label class="form-check-label">
                                                        <input type="hidden" asp-for="@Model.RoleCalims[i].DisplayValue" />
                                                        <input type="checkbox" class="checkBoxClass form-check-input-styled" asp-for="@Model.RoleCalims[i].IsSelected">
                                                        @Model.RoleCalims[i].DisplayValue.Split('.')[2]
                                                        <br />
                                                        <br />
                                                        @Model.RoleCalims[i].DisplayValue.Split('.')[1]
                                                    </label>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                }
                            </div>
                        </div>


                    </div>
                </div>


                <ul class="fab-menu fab-menu-fixed fab-menu-bottom-left" data-fab-toggle="click">
                    <li>
                        <a asp-action="Roles" class="fab-menu-btn btn btn-light btn-float rounded-round btn-icon">
                            <i class="fab-icon-open icon-arrow-right13"></i>
                            <i class="fab-icon-close icon-arrow-right13"></i>
                        </a>
                        <button type="submit" class="fab-menu-btn btn bg-blue-400 btn-float rounded-round btn-icon">
                            <i class="fab-icon-open icon-pencil4"></i>
                            <i class="fab-icon-close icon-pencil4"></i>
                        </button>
                    </li>
                </ul>


            </form>



samedi 10 juin 2023

How to assign macro on checkbox in google sheet

Not able to run macro in mobile. i already use button by inserting image but it does not work on mobile phone.




How to align checkboxes created using roles to the center of the cell in QTableWidget?

In my Qt C++ Windows application, I create checkboxes in my table using roles:

QTableWidgetItem* item = new QTableWidgetItem();
item->setData(Qt::CheckStateRole, QVariant::fromValue(dev.is_active ? Qt::Checked : Qt::Unchecked));
ui.tableWidget->setItem(i, ui_columns_positions.at(table_columns::IsActive), item);

The problem is that checkboxes are left-aligned. I need to align them to the center of the cell. left-aligned checkboxes

I've already tried various alignment methods, but none of them work. For example, I created a style for alignment, I made a delegate class - nothing worked. How to align checkboxes created using roles to the center of the cell in QTableWidget?




Couldn't get value from Checkbox using name attribute in ASP.NET MVC

I put checkbox in .cshtml page with name attribute named "bSendEmail" to get the value as a boolean for further process. In post action method, I used a boolean parameter to get whether the checkbox is checked or not but I didn't get the value as true even the checkbox is checked. It always gives false.

I posted below what I am have tried

In .cshtml:

<form method="post" asp-action="ItemIndex">
    <div class="row">
        <div class="col-xl-12 text-center mt-3">
            @if (g_EnableEmail == Constants.GeneralIndicator.Yes)
            {
                <input type="checkbox" id="chkSendMail" name="bSendEmail" class="my-checkbox" />
            }
            else
            {
                <input type="checkbox" id="chkSendMail" name="bSendEmail" class="my-checkbox" disabled />
                <input type="hidden" name="bSendEmail" />
            }
            <label for="chkSendMail" class="head-label2">Send Email Notification</label>
        </div>
    </div>

    <div class="row">
        <div class="col-xl-12 text-center mt-10">
            <button type="submit" asp-route-bConfirm="@false" asp-action="ItemIndex" class="genric-btn info circle"><i class="fa fa-check"></i> Save</button>
            <button type="submit" asp-route-bConfirm="@true" asp-action="ItemIndex" class="genric-btn green circle"><i class="fa fa-check"></i> Finalize</button>
            <a asp-controller="CreditNotes" asp-action="CreateEdit" asp-route-id="@Model.CreditNoteId" class="genric-btn danger circle "><i class="fa fa-times "></i> Cancel</a>
        </div>
    </div>
</form>

In Controller:

[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> ItemIndex(bool bConfirm, bool bSendEmail)
{
    .... My codes are here
}

I couldn't get proper value from the parameter named "bSendEmail". Please help me to resolve this. Thanks in Advance




vendredi 9 juin 2023

Get values to left and right of merged cell with checkbox VBA Macro

@FunThomas answered this in part I. https://stackoverflow.com/a/76439568/21278470

enter image description here

My question now, I am modifying the code to ALSO capture the ranges B:I to the left of the checkbox. Currently it is only set up for grabbing Y:AB

This is the code below that works correctly for grabbing only one range; however no matter how I try to modify it, it seems like it is setup only to have one range.

Sub copySelected()
Dim shtSource As Worksheet
Dim wbDest As Workbook
Dim sourceRng As Range
Dim wsDest As Worksheet
Dim cb As CheckBox


Set shtSource = ThisWorkbook.Worksheets("RFQ FORM INT") 'where the data is
   Set wbDest = Workbooks.Add
    Set wsDest = wbDest.Sheets("Sheet1")
    
For Each cb In shtSource.CheckBoxes 'loop through all checkboxes
If cb.Value = 1 Then 'if the checkbox has been selected then...
    ' Figure out the area of data we want to copy
    Dim sourceRange As Range
    Set sourceRange = shtSource.Range("Y" & cb.TopLeftCell.MergeArea.row, "AB" & cb.TopLeftCell.row)
    Set sourceRange = sourceRange.Resize(cb.TopLeftCell.MergeArea.Rows.Count)
    sourceRange.Copy    '...copy the corresponding range of data...
    With wsDest
        Dim row As Long
        row = .Range("Y" & .Rows.Count).End(xlUp).row + 1
        If row < 15 Then row = 15
        With .Cells(row, "Y")
            .PasteSpecial xlPasteValuesAndNumberFormats '...Paste info
            .PasteSpecial xlPasteFormats
            .PasteSpecial xlPasteColumnWidths
        End With
    End With
End If
Next cb
End Sub

I wrote the below VBA to copy the ranges B:I and Y:AB using union, but only the formatting is pasting, no text. And the Code only grabs one checkbox row instead of all checked rows.

Any way to modify the first code to grab multiple ranges of this merged row?

Sub copySelected()
Dim shtSource As Worksheet
Dim wbDest As Workbook
Dim sourceRng As Range
Dim wsDest As Worksheet
Dim cb As CheckBox


Set shtSource = ThisWorkbook.Worksheets("RFQ FORM INT") 'where the data is
   Set wbDest = Workbooks.Add
    Set wsDest = wbDest.Sheets("Sheet1")
    
For Each cb In shtSource.CheckBoxes 'loop through all checkboxes
If cb.Value = 1 Then 'if the checkbox has been selected then...
    ' Figure out the area of data we want to copy
    Dim sourceRange1 As Range, sourceRange2 As Range, multiplerange As Range
    Set sourceRange1 = shtSource.Range("Y" & cb.TopLeftCell.MergeArea.row, "AB" & cb.TopLeftCell.row)
    Set sourceRange1 = sourceRange1.Resize(cb.TopLeftCell.MergeArea.Rows.Count)
    Set sourceRange2 = shtSource.Range("B" & cb.TopLeftCell.MergeArea.row, "I" & cb.TopLeftCell.row)
    Set sourceRange2 = sourceRange2.Resize(cb.TopLeftCell.MergeArea.Rows.Count)
    Set multiplerange = Application.Union(sourceRange1, sourceRange2)
    multiplerange.Copy    '...copy the corresponding range of data...
    
    With wsDest
        Dim row As Long
        row = .Range("B" & .Rows.Count).End(xlUp).row + 1
        If row < 15 Then row = 15
        With .Cells(row, "B")
            .PasteSpecial xlPasteValuesAndNumberFormats '...Paste info
            .PasteSpecial xlPasteFormats
            .PasteSpecial xlPasteColumnWidths
        
        End With
    End With
End If
Next cb
End Sub



Checkbox - getting value [duplicate]

My purpose is to get all of the values that the user has selected, but for some reason, I'm only receiving the first value instead of all of them. What am I doing wrong? I would appreciate any help!

Html:

<div class="checkbox-grid_register" id="genres_register" name="genres">
     
 </div>

Python:

genres = request.POST["genres"]



c# WPF MVVM: Checkbox doesnt Fire Event "Checked" or "Unchecked"

im new to the MVVM pattern and i got a problem with checkboxes inside of a listview.. When i put a checkbox as item into a listview the events "checked" and "unchecked" does not fire. But when i add a checkbox outside of the listview e.g. in a stackpanel, the events fire.

Could anybody explain the problem?

Thank you in advance.

This is my used code:

xmlns:behav="http://schemas.microsoft.com/xaml/behaviors"
<Border Grid.Row="1" Grid.Column="0" BorderThickness="2" Grid.RowSpan="3" BorderBrush="{StaticResource MainMenuColor}">
  <ListBox ItemsSource="{Binding ListBoxItems}" Background="Transparent" Foreground="{StaticResource MainMenuColor}">
    <ListBox.ItemTemplate>
      <DataTemplate>
        <CheckBox FontFamily="{StaticResource FontProtokoll}" IsChecked="{Binding IsChecked}" Content="{Binding Path=Text}" Foreground="{StaticResource MainMenuColor}">
          <behav:Interaction.Triggers>
            <behav:EventTrigger EventName="Checked">
              <behav:InvokeCommandAction Command="{Binding CheckedOrUncheckedCommand}"/>
            </behav:EventTrigger>
          </behav:Interaction.Triggers>
        </CheckBox>
      </DataTemplate>
    </ListBox.ItemTemplate>
  </ListBox>
</Border>




mercredi 7 juin 2023

R/Shiny - Scrollable datatable with checkboxes and total count

I have a datatable to which I add a checkbox column, and can click on individual boxes. Also, have an actionButton that can select or deselect all the checkboxes, a total count of the clicked boxes, and a search box. Everything works except for three things:

  1. If I click on individual checkboxes, the count doesn't change. (It works correctly, though, for the whole set.)
  2. If I click on a few checkboxes and I immediately search for a term or sort by any column, the checkboxes are cleared.
  3. There is no sorting for the checkbox column. It would be ideal if sorting the checkboxes could accumulate all those that were clicked at the top, to be able to see in one go what has been selected.

Any idea?

Thanks

library(shiny)
library(DT)

data <- data.frame(
  Checkbox         = rep(FALSE, 20),
  Name             = c("John", "Jane", "Michael", "Sara", "David","John1", "Jane1", "Michael1", "Sara1", "David1",
                       "John2", "Jane2", "Michael2", "Sara2", "David2","John3", "Jane3", "Michael3", "Sara3", "David3"),
  Volume           = round(100 * runif(20,0,1),0),
  stringsAsFactors = FALSE
)

ui <- fluidPage(
  titlePanel("Scrollable Datatable with Checkbox"),
  sidebarLayout(
    sidebarPanel(
      actionButton("selectBtn", "Select/Deselect All"),
      numericInput("selectedCount", "Selected Rows", 0, min = 0, max = nrow(data), width = "100%")
    ),
    mainPanel(
      DTOutput("myTable")
    )
  )
)

server <- function(input, output, session) {
  # Render the datatable
  output$myTable <- renderDT({
    datatable(data, 
              selection    = 'none',
              options      = list(
                scrollX    = TRUE,
                scrollY    = "400px",
                paging     = FALSE,
                searching  = TRUE,
                order      = list(1, 'asc'),
                columnDefs = list(
                  list(className = 'dt-center', targets = c(1, 3)),
                  list(className = 'dt-left', targets = 2),
                  list(targets = 1, render = JS(
                    "function(data, type, full, meta) {",
                    "var checkboxId = 'checkbox_' + meta.row;",
                    "return '<input type=\"checkbox\" id=\"' + checkboxId + '\" class=\"row-checkbox\" ' + (data ? 'checked' : '') + '></input>';",
                    "}"
                  ))
                )
              )
    )
  })
  
  # Select/Deselect all checkboxes     <============== (this works)
  observeEvent(input$selectBtn, {
    if (input$selectBtn %% 2 == 1) {
      data$Checkbox <- TRUE
    } else {
      data$Checkbox <- FALSE
    }
  # Update the datatable
    replaceData(proxy = dataTableProxy("myTable"), data, resetPaging = FALSE)
  # Update the selected count
    updateNumericInput(session, "selectedCount", value = sum(data$Checkbox))
  })
  
  # Row checkbox selection             <============== (this part doesn't work)
  observeEvent(input$myTable_cells_selected, {
    clicked_rows <- unique(input$myTable_cells_clicked$row)
    data$Checkbox[clicked_rows] <- !data$Checkbox[clicked_rows]
  # Update the datatable
    replaceData(proxy = dataTableProxy("myTable"), data, resetPaging = FALSE)
  # Update the selected count
    updateNumericInput(session, "selectedCount", value = sum(data$Checkbox))
  })
}

shinyApp(ui, server)



How to fix checkbox tick offset in chrome?

I'm developing a checkbox for a component library and the designers want me to use a custom SVG for the tick mark. The problem is that on Firefox the checkbox looks correct, but on Chrome the SVG is offset towards the top.

Changing the flex properties on the container doesn't seem to fix the problem.

Firefox

Firefox looking good

Chrome

Chrome offset

My JSX:

<label>
  <input
    type="checkbox"
    className={'checkbox'}
    {...rest}
    ref={ref}
  />
  <span className="checkbox-label">
    {label}
  </span>
</label>

My CSS:

.checkbox {
  position: absolute;
  opacity: 0;
  z-index: -1;
}

/* Label style */
.checkbox + .checkbox-label {
  cursor: pointer;
  display: flex;
  gap: 8px;
}

/* Checkbox un-checked style */
.checkbox + .checkbox-label::before {
  box-sizing: border-box;
  content: "";
  border: 1px solid #e2e2e2;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  max-width: 24px;
  width: 24px;
  height: 24px;
}

/* Checked checkbox style */
.checkbox:checked + .checkbox-label::before {
  content: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-check'><polyline points='20 6 9 17 4 12'></polyline></svg>");
  color: white;
  background-color: #bcbcbc;
  border: none;
}

Any idea what I'm missing here?




why the disabled field of the mat-checkbox component may not work

I need this component to accept the disabled value depending on the variable, the most common use of a component. But it does not work, I did everything as in the documentation

I imported the module as in the documentation, the component itself worksenter image description here but field with disabled doesn't work it doesn't matter if disabled is set through a variable, or through true - nothing Ыetting disabled form formGroup works, but i can't enter a specific condition there




lundi 5 juin 2023

How do I Apply checkbox reset to only one sheet

I am trying to use the below script to automatically change checkboxes to false. It works fine but.... I now need to apply this ONLY to the sheet titled 'TASKS', and not to any others within the spreadhsheet.

Can anyone assist? image - https://i.stack.imgur.com/2cUzh.jpg

***this is also my first ever javascript attempt. previous to this, i did some myspace tamporing 15 - 20 years ago




NextJS with Chakra-UI Checkbox managing display of text

I'm fighting my way through learning nextjs, postgre, react query etc. Have managed to write my basic structure in nextjs using chakra components, but as I never dealt with programming before I got quite some problems with react-query to fetch supabase data etc.

Right now I'm stuck with a checkbox problem.

I structured all of my page parts into single components.

Now I want to hide text in the lower part of the code until the corresponding checkbox in the upper part has been selected. I managed to setup a "checkboxCheck" component in the corresponding part which hides the text, but creates a separate checkbox at the spot where it is needed. this should be triggered at a very different spot (much earlier).

checkboxes are setup in line 44-48, triggered text is in line 161 and following.

I guess I need to set a class or sth for the checkbox and wrap it around the function, but I don't get it what to do exactly. Maybe someone can help me please?!

I read a lot of different threads, but wasn't able to find what I need.




dimanche 4 juin 2023

Vaadin grid becomes empty, when using ComboboxRenderer

Vaadin version is 8.10.1

Adding the addon:

    <dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>grid-renderers-collection-addon</artifactId>
        <version>2.7.0</version>
    </dependency>

and in the grid defining the renderer like that:

    CheckboxRenderer renderer = new CheckboxRenderer<>(Payment::setSelectedToMultiAction);
    paymentGrid.addColumn(Payment::getSelectedToMultiAction)
            .setRenderer(renderer)
            .setCaption("Selection");

But the grid shown empty. With no error in Chrome's js console:

enter image description here

If we remove the renderere, everything is displayed.

    CheckboxRenderer renderer = new CheckboxRenderer<>(Payment::setSelectedToMultiAction);
    paymentGrid.addColumn(Payment::getSelectedToMultiAction)
    //        .setRenderer(renderer)
            .setCaption("Selection");



samedi 3 juin 2023

Checkbox not clickable with javascript. .click() is not a function

I've tried automating a checkbox to click with JavaScript, in Google Chrome.

This is what the inspector of the browser shows me when I inspect the checkbox:

<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-square" data-icon="Square" aria-hidden="true" focusable="false"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect></svg>

This is how I've tried to click the button:

document.getElementsByClassName('lucide lucide-square')[0].click();

It does recognise the element but it doesn't click it.

It returns the error:

VM3971:1 Uncaught TypeError: document.getElementsByClassName(...)[0].click is not a function
    at <anonymous>:1:60

Anybody can help with this, please?

I've tried also .onclick or also to call the element with querySelector, but it doesn't work.

I was expecting the checkbox to work like other ones on the same website, which were all clickable with .click()




vendredi 2 juin 2023

Checkbox WPforms not visible mobile

WP FORMS:

Suddenly checkboxes are not visible on mobile anymore. See added pictures mobile / PC ... already tried several CSS codes, but none of them seems to work.. PC MOBILE

Please help.

Already tried several CSS codes, please help me




How can I filter each name in a column based on having at least one checked box on Google Sheets?

Here's what I have:

Column A lists names of volunteers.

Columns B to S consist entirely of checkboxes (with column headings).

I would like to use a formula elsewhere in the spreadsheet to filter out all volunteers that are serving in at least one area (as indicated by checkboxes ie. true/false). I would prefer not to use a helper column for this. Any help much appreciated.

Check out my sample here:

I tried using the filter function, sumif, sumproduct, nothing seems to work without getting extremely complicated or requiring a helper column.