juricin
Posts: 0
Joined: Tue Jan 13, 2015 5:09 am

Change label within grid cell on click

Hi, im stuck.

I am mapping from storage to a label within a grid cell. I'd like to click on the grid cell which will map something different from storage and have the grid cell background change color.

thanks in advance, ante

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Change label within grid cell on click

Hi juricin,,

Here is plan for this goal:

  1. Add grid cell "click" JS event handler.

  2. Populate it with following JS code:

    pre

    var cell = jQuery(this);

    //Change cell background
    cell.css("background", "#f00");

    //Where "labelName" is your label name.
    var label = cell.find('[name="labelName"]');

    //Change label background
    label.css("background", "#0f0");

    /pre

    Regards.

juricin
Posts: 0
Joined: Tue Jan 13, 2015 5:09 am

Change label within grid cell on click

thanks Yurii, sort of there.

grid cell background is changing, great.

unresolved:

I have two labels in this grid cell. One label is simple text with the word 'Good' this needs to change to 'Received' on click in same position

the second label 'good_count' is currently mapping from storage 'received_count' and this needs be replaced with a new label to map 'received_amount' in the same position. do i even need a new label? or just target the same label?

and return click takes back to previous

thanks, ante

juricin
Posts: 0
Joined: Tue Jan 13, 2015 5:09 am

Change label within grid cell on click

Am i supposed to comment directly? see below. thanks, ante

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Change label within grid cell on click

HI Juricin,

It seems you just need hide "good_count" and show "received_count" label.

Here is code:

pre

Apperyio("good_count").hide();
Apperyio("received_count").show();

/pre

Regards.

juricin
Posts: 0
Joined: Tue Jan 13, 2015 5:09 am

Change label within grid cell on click

Great! that worked.

one last thing regarding this:

if you click on the grid cell again it returns to previous state.

thanks, ante

Ihor Didevych
Posts: 0
Joined: Wed Nov 19, 2014 7:55 pm

Change label within grid cell on click

Hello,

You should add a flag that will store the state
var flag_checked;
if (flag_checked){
Apperyio("good_count").hide();
Apperyio("received_count").show();
flag_checked = true;
}else{
Apperyio("good_count").show();
Apperyio("received_count").hide();
flag_checked = false;
}

juricin
Posts: 0
Joined: Tue Jan 13, 2015 5:09 am

Change label within grid cell on click

Hi Ihor, thanks but this has now disabled the click event and its not working.

Ante

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

Change label within grid cell on click

Hi Ante -

Could you please clarify what exactly is not working? How you implemented the above code?

juricin
Posts: 0
Joined: Tue Jan 13, 2015 5:09 am

Change label within grid cell on click

Hi Illya,

On the grid cell component there is a click event that runs javascript as per Ihor's suggestion

var flag_checked;
if (flag_checked){
Apperyio("good_count_label").hide();
Apperyio("good_amount_label").show();
Apperyio("textGood").hide();
Apperyio("textRaised").show();
flag_checked = true;
}else{
Apperyio("good_count_label").show();
Apperyio("good_amount_label").hide();
Apperyio("textGood").show();
Apperyio("textRaised").hide();
flag_checked = false;
}

This is to show and hide labels within the grid cell when a user clicks to display different text and different storage from mapping.

Yurri's suggestion further above works but once I added flag_checked it no longer executes the click on event or show/hide labels.

thanks, ante

Return to “Issues”