enable or disable field

Questionsenable or disable field
german asked 10 years ago

compare two dropdwon box and enable third column

5 Answers
Abu Ghufran answered 10 years ago

Some custom js level checks would be required.
$col["editrules"] = array("readonly"=>true, "readonly-when"=>"check_value");

In html, script tag: this will make field readonly when client_id in 3,6,7,8,9. Similarly you can compare it with your fields.

// readonly conditional function – when return true, field will be readonly
function check_value(formid)
{
client_id = jQuery("input[name=client_id]:last, select[name=client_id]:last",formid).val();
client_id = parseInt(client_id);

if (jQuery.inArray(client_id,[3,6,7,8,9]) != -1)
return true;
}

http://pastebin.com/wb3eraRQ

germanmary.p answered 10 years ago

function chpo()
{
freproductid = jQuery("input[name=freproductid]:last, select[name=freproductid]:last",formid).val();
freproductid = parseInt(freproductid);

productid = jQuery("input[name=eproductid]:last, select[name=productid]:last",formid).val();
freproductid = parseInt(freproductid);
productid = parseInt(productid);
if (jQuery(productid)==jQuery(freproductid))
return true;
//if (jQuery('#freproductid',form).val() == jQuery('#productid',form).val()) jQuery('#freeqty',form).hide(); else jQuery('#freeqty',form).show() }";

}

i used like this but the field is not set read only

$col = array();
$col["title"] = "Free Qty"; // caption of column
$col["name"] = "freeqty";
$col["width"] = "100";
$col["editable"] = true;
$col["isnum"] = true;
$col["isnull"] = true;
$col["editrules"] = array("readonly"=>true, "readonly-when"=>"chpo");
$col["formoptions"] = array("rowpos"=>"3", "colpos"=>"1");
//$col["editoptions"] = array("tabindex"=>"102");
$cols[] = $col;

Abu Ghufran answered 10 years ago

I've sent the working demo code. Rest is your application logical work and it is outside the scope of phpgrid.
You can put alert statements to debug inside function.

german answered 10 years ago

Sir

you may be correct that it MAY out side of the scope BUT I AM USING PHP GRID FOR MY PROJECT ANT IT IS PURCHASED ONE.YOU ARE SAYING THAT YOU CANNOT HELP ME OUT TO SOLVE THE ISSUE.I CAN VERY WELL USE NORMAL PHP.THERE I CAN WRITE THE FUNCTION AND CALL AS I WISH.

THE EXAMPLE THAT YOU GAVE IS NOT WORKING IT SHOWS BLANK PAGE

JUST GIVE SOME SOLUTION IT IS JUST A SIMPLE PAGE WITH TWO DOPDOWN IF TWO IDS ARE EQUAL THE THIRD COLUMN SHOULD NOT BE VISIBLE

Abu Ghufran answered 10 years ago

Hello,

May be there is some understanding issue. If you can send your code, screenshot of current and screenshot expected result then i can point out the issue OR make a new demo for your case.

Beside this, i don't have your working project + database. So all changes i suggest in your code is just for idea.
You will need to run/debug in your complete project.

You can email me at [email protected]

Your Answer

13 + 12 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?