jeudi 25 janvier 2018

button enable on grid checkbox

I have one gridview which checkbox,

 <asp:GridView ID="GriduwgDocuments" AutoGenerateColumns="False" runat="server"
            EnablePersistedSelection="true" AllowPaging="True" AllowSorting="True" GridLines="None"
            Width="960px"  PageSize="25">
                           <PagerSettings Position="Top"></PagerSettings>
            <RowStyle CssClass="result-grid-row" />
            <AlternatingRowStyle CssClass="result-grid-row-alternate" />
            <SelectedRowStyle CssClass="result-grid-row-selected" />
            <HeaderStyle Height="20px" CssClass="result-grid-header" />
             <Columns>
             <asp:TemplateField >
     <ItemTemplate>
       <asp:CheckBox ID="chkBxSelect" runat="server"  OnCheckedChanged="cbRowChanged_CheckedChanged" />  
     </ItemTemplate>

  </asp:TemplateField>

and button,

  <asp:Button ID="btnGetDocs" runat="server" Text="Download Selected Docs" 
                                                CssClass="Button" 
                                                Width="140px" Enabled="False" />

What I am trying to do is , when page load first time my button is Enabled="False" and as soon as client checked any checkbox of grid, my button should be Enabled="true" . I mean clickable.

on OnCheckedChanged of checkbox ,its goes to behind the code cbRowChanged_CheckedChanged.

please advice !!




Get checked items in treeview

I'm using a third party .dll which contains a type of object called Layer. I have a collection of these layers in my viewmodel. In my view, I have a TreeView whose ItemsSource is bound to the collection of layers. I also have a checkbox with each item.

I want to somehow get the all of the checked Layer items.

Normally I would have just make a public boolean property called IsChecked in the object's class, but Layer does not have a property for that.

Here's the xaml:

<TreeView Grid.Row="1" Grid.Column="0">
    <TreeViewItem Header="Shape Files" ItemsSource="{Binding Layers}" >
        <TreeViewItem.ItemTemplate>
            <DataTemplate>
                <StackPanel>
                    <CheckBox Content="{Binding Name}" />
                </StackPanel>
            </DataTemplate>
        </TreeViewItem.ItemTemplate>
    </TreeViewItem>
</TreeView>

Here's the view model:

public ObservableCollection<Layer> Layers
{
    get { return mapModel.Layers; }
    set { mapModel.Layers = value; OnPropertyChanged("Layers"); }
}

And here's an example of what this looks like:

enter image description here

I know one way would be to have the checked function of the checkboxes bind to a command, with the item itself being sent as a command parameter. Is that really the best way to do this though?




c# - Panel scrolling automatically

I have an UserControl and inside it I have some controls and one of these controls is a CheckBox. This CheckBox performs a CheckedChanged action that calls a method and this method sets some of the controls of the Panel to Enabled or Visible.

When I click to check the CheckBox the Panel where all these controls are inserted scrolls down automatically like the images below.

How could I stop the Panel scrolling down after checking the CheckBox?

enter image description here Inicial position

enter image description here Position after checking the CheckBox

The code is below

The CheckBox Action

private void usuarioMedicoCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            if(usuarioMedicoCheckBox.Checked)
            {
                carregarMedicos();
            } else
            {
                medicos = null;
            }

            usuarioMedicoComboBox.Enabled = usuarioMedicoCheckBox.Checked;
            cadastrarMedicoButton.Enabled = usuarioMedicoCheckBox.Checked;
        }

Method carregarMedico

private void carregarMedicos()
        {
            processandoDados(true);

            ParseQuery<Classes.Medico> query = new ParseQuery<Classes.Medico>();

            query.OrderBy("nomeCompleto").FindAsync().ContinueWith(resultado => {
                if (resultado.IsCompleted && !resultado.IsFaulted)
                {
                    medicos = resultado.Result.ToList();

                    atualizarMedicosComboBoxDelegate atualizarMedicosComboBoxD = new atualizarMedicosComboBoxDelegate(atualizarMedicosComboBox);
                    this.Invoke(atualizarMedicosComboBoxD, new object[] { });
                } else
                {
                    MessageBox.Show("Houve um erro ao buscar os médicos", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                processandoDadosDelegate processandoDadosD = new processandoDadosDelegate(processandoDados);
                this.Invoke(processandoDadosD, new object[] { false });
            });
        }

Method atualizarMedicosComboBox

private void atualizarMedicosComboBox()
        {
            usuarioMedicoComboBox.Items.Clear();

            if (medicos != null && medicos.Count() > 0)
            {
                foreach(Classes.Medico medico in medicos)
                {
                    usuarioMedicoComboBox.Items.Add(medico.nomeCompleto);
                }
            } else
            {
                usuarioMedicoComboBox.Items.Add("Não há médicos cadastrados");
            }
        }

Method processandoDados

private void processandoDados(bool acao)
        {
            if (acao)
            {
                nomeCompletoTextBox.Enabled = false;
                emailTextBox.Enabled = false;
                cpfMaskedTextBox.Enabled = false;
                selecionarFotoButton.Enabled = false;
                usuarioMedicoCheckBox.Enabled = false;
                usuarioMedicoComboBox.Enabled = false;
                cadastrarMedicoButton.Enabled = false;
                usuarioAdmCheckBox.Enabled = false;
                permissoesPacientesGroupBox.Enabled = false;
                permissoesMedicosGroupBox.Enabled = false;
                permissoesUsuariosGroupBox.Enabled = false;
                salvarUsuarioButton.Visible = false;
                salvarUsuarioProgressBar.Visible = true;
            } else
            {
                nomeCompletoTextBox.Enabled = true;
                emailTextBox.Enabled = true;
                cpfMaskedTextBox.Enabled = true;
                selecionarFotoButton.Enabled = true;
                usuarioMedicoCheckBox.Enabled = true;

                if (usuarioMedicoCheckBox.Checked)
                {
                    usuarioMedicoComboBox.Enabled = true;
                    cadastrarMedicoButton.Enabled = true;
                }
                else
                {
                    usuarioMedicoComboBox.Enabled = false;
                    cadastrarMedicoButton.Enabled = false;
                }

                usuarioAdmCheckBox.Enabled = true;
                salvarUsuarioButton.Visible = true;
                salvarUsuarioProgressBar.Visible = false;

                if(!usuarioAdmCheckBox.Checked)
                {
                    permissoesPacientesGroupBox.Enabled = true;
                    permissoesMedicosGroupBox.Enabled = true;
                    permissoesUsuariosGroupBox.Enabled = true;
                }
            }
        }




CSS3 select an ID name for check boxes apply changes

I'm on a web app build and I encounter some trouble to select multiple ID. I would like to use theses IDs to apply movement on a wrapper, but the selector don't make the job.


there is the unuseful code:

div[id*="article_"]:checked ~ .article_wrapper {moving wrapper code}

The name selector need to be effective with ".article_001" to ".article_999", so I don't want to have a huge copy/paste on my stylesheet.


If someone know how to do it perfectly and of course I don't want to use something else to CSS selectors.




Material-UI Checkbox & Switch

So what I'm trying to do is to uncheck a checkbox, or switch component when another userinput changes. Now the problem is, that the internal SwitchBase component's checked prop is changing accordingly how i want it to change, but the checked state is not. (this only happens when i want to programatically uncheck one of these components) This result in an unchecked checkbox which is visually still checked.

Does anyone have a solution to this?

[case shown on this image1




How to load Text from TextField, checkbox, RadioButton, ComboBox to one Big Text Field

I'm beginner on Java and I'm writing a simple program for recruiting employees. I have few Questions with JtextField, few checkbox with text, RadioButton with text and Combobox. I need the data entered in the text windows, checkbox, drop-down list to be thrown into the large window on the right. At the moment there are only data from the text windows, but not from the top just in the middle of the field. Please help.

package appka;

import javax.swing.*;

import java.awt.Checkbox; import java.awt.event.*;

public class CzwartaApp {

public static void main(String[] args) {
    // Klasy obiektow
    JFrame frame = new JFrame("Czwarta Aplikacja");

    JButton btnSubmit = new JButton("Wypisz");
    JButton btnExit = new JButton("Wyjdz");

    JLabel lbl1 = new JLabel("imię");
    JLabel lbl2 = new JLabel("nazwisko");
    JLabel lbl3 = new JLabel("stanowisko");
    JLabel lbl4 = new JLabel("E-mail");
    JLabel lbl5 = new JLabel("");
    JLabel lbl6 = new JLabel("Jakie znasz języki programowania?");
    JLabel lbl7 = new JLabel("Wybierz poziom języka angielskiego?");
    JLabel lbl8 = new JLabel("Wybierz kurs programowania?");
    JLabel lbl9 = new JLabel("Dane Kontaktowe");

    JTextField tf1 = new JTextField();
    JTextField tf2 = new JTextField();
    JTextField tf3 = new JTextField();
    JTextField tf4 = new JTextField();
    JTextField tf5 = new JTextField();

    Checkbox checkbox1 = new Checkbox("Java");
    Checkbox checkbox2 = new Checkbox("Python");
    Checkbox checkbox3 = new Checkbox("Inne");

    JRadioButton btn1 = new JRadioButton();
    btn1.setText("podstawowy");
    JRadioButton btn2 = new JRadioButton();
    btn2.setText("średnio-zaawansowany");
    JRadioButton btn3 = new JRadioButton();
    btn3.setText("zaawansowany");
    ButtonGroup group = new ButtonGroup ();
    group.add(btn1); group.add(btn2); group.add(btn3);

    JComboBox kurs = new JComboBox();
    kurs.addItem("FrontEnd Developer");
    kurs.addItem("BackEnd Developer");

    // Pozycjonowanie
    lbl1.setBounds(20, 20, 100, 20);
    tf1.setBounds(20, 70, 100, 20);
    lbl2.setBounds(20, 120, 100, 20);
    tf2.setBounds(20, 170, 100, 20);
    lbl3.setBounds(20, 220, 100, 20);
    tf3.setBounds(20, 270, 100, 20);
    lbl4.setBounds(20, 320, 100, 20);
    tf4.setBounds(20, 370, 100, 20);
    tf5.setBounds(500, 20, 250, 300);
    lbl5.setBounds(20, 420, 300, 20);
    lbl6.setBounds(200, 20, 250, 20);
    lbl7.setBounds(200, 220, 250, 20);
    lbl8.setBounds(200, 350, 250, 20);
    lbl9.setBounds(500, 50, 200, 20);
    btnSubmit.setBounds(20, 470, 100, 20);
    btnExit.setBounds(220, 470, 100, 20);
    checkbox1.setBounds(200, 70, 250, 20);
    checkbox2.setBounds(200, 120, 250, 20);
    checkbox3.setBounds(200, 170, 250, 20);
    btn1.setBounds(200, 250, 250, 20);
    btn2.setBounds(200, 280, 250, 20);
    btn3.setBounds(200, 310, 250, 20);
    kurs.setBounds(200, 380, 250, 20);


    // Obsluga zdarzen
    btnSubmit.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent e){

            String imie = tf1.getText();
            String nazwisko = tf2.getText();
            String stanowisko = tf3.getText();
            String email = tf4.getText();

            tf5.setText(imie+" "+nazwisko+" "+stanowisko+" "+email);

        }

    });
    btnExit.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent e){
            System.exit(0);
        }
    });
    // Dodanie do okna
    frame.add(btnSubmit); frame.add(btnExit);
    frame.add(tf1); frame.add(tf2); frame.add(tf3);frame.add(tf4);frame.add(tf5);
    frame.add(lbl1); frame.add(lbl2); frame.add(lbl3); frame.add(lbl4);frame.add(lbl5);
    frame.add(lbl6);frame.add(lbl7);frame.add(lbl8);frame.add(lbl9);
    frame.add(checkbox1); frame.add(checkbox2); frame.add(checkbox3);
    frame.add(btn1); frame.add(btn2); frame.add(btn3);
    frame.getContentPane().add(kurs);
    frame.setSize(800, 600);
    frame.setLayout(null);
    frame.setVisible(true);
}

}




Why checkbox isn't work as expected with inline edit - Kendo Grid?

I've a Kendo Grid in my application, I use ClientTemplate for checkbox in a column. The checkbox isn't display when the page loads, but the property(CheckName) value is true, so it should be. Another thing is, when I click to the checkbox, and after that click on another, the previous checked checkbox dissapears. I use InCell edit, maybe it cause the problem? Any advice'd be helpful.

@(Html.Kendo().Grid<myViewModel>()
    .Name("mygrid")
    .Filterable()
    .Sortable()
    .Editable(e => e.Mode(GridEditMode.InCell))
    .Columns(columns =>
    {
        columns.Bound(c => c.Id).Visible(false);
        columns.Bound(c => c.CheckName).Title("Default/Active")
                .ClientTemplate("<input type='checkbox' #= IsActive ? checked='checked' : '' # onclick='setCheckName()' id='CheckNameid' />")

        columns.Bound(c => c.Name);
    })
    .DataSource(ds => ds
        .Ajax()
        .Read(r => r.Action("ReadData", "MyContr"))
        .Update(u => u.Action("UpdateData", "MyContr"))
        .AutoSync(true)
        .Model(model =>
        {
            model.Id(m => m.Id);
            model.Field(m => m.CheckName);
            model.Field(m => m.Name);
        })
    )
)