Forums: [SOLVED] Disable Record Editing and Additon of Child Tables - Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

[SOLVED] Disable Record Editing and Additon of Child Tables Rate Topic: -----

#1 User is offline   i.NoLim 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 93
  • Joined: 11-September 17

Posted 07 February 2018 - 12:11 AM

I have 3 tables: Family, Applicant, Charges. All these tables contain a column called "Status." Their relationship is a follows:

Master | Child | Linked Field
Family - Applicant - Family_ID
Applicant - Charges - Applicant_ID

Right now I have so that when the "Status" changes for the master table the "Status" for the child tables also changes.

For example, if the "Status" for Applicant C changes from 'Active' to 'Inactive' all the "Charges" that share that same 'Applicant_ID' become 'Inactive' as well.

Now I would like it so that when the status of the Master table is set to 'Inactive' the "Edit," "Inline Add," and "Add new" buttons for the child entries that have that same "Family_ID" and/or "Applicant_ID" are disabled.

For example if I set the "Status" for the Jones family, I would not be able to edit or add new Applicants or Charges to this family.

I saw this, but I'm not sure how to apply it to the child tables.


https://xlinesoft.co...ord_editing.htm
0

#2 User is offline   jadach 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 467
  • Joined: 26-April 08
  • Gender:Male
  • Location:New York

Posted 07 February 2018 - 07:45 PM

On the Is Record Editable for your table you can add code similar to this:
if (values["Status"] == "Inactive")
  return false;
else
  return true;


As far as adding new reocrds, you will need to do something like this on your child list pages:

ListPage Before Process
XVar data = pageObject.getMasterRecord();
if (data != null)
{
string strSQLExists = "select * from dbo.Family where Family_ID='"+data["Family_ID"].ToString()+"' and Status='Inactive'";
XVar rsExists = CommonFunctions.db_query(strSQLExists, null);
XVar data1 = CommonFunctions.db_fetch_array(rsExists);
if(data1)
{
pageObject.setProxyValue("AddRecord", 1);
}
else
{
pageObject.setProxyValue("AddRecord", 0);
}
}


ListPage Javascript onload
var id = "addButton";
var button = $("[id^=" + id + "]");
if (proxy['AddRecord']==1){
button.hide();
}

var id = "inlineAdd";
var button1 = $("[id^=" + id + "]");
if (proxy['AddRecord']==1){
button1.hide();
}


This may not work exactly for you as is, but it should get you going in the right direction.
-jerry
0

#3 User is offline   i.NoLim 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 93
  • Joined: 11-September 17

Posted 07 February 2018 - 11:57 PM

View Postjadach, on 07 February 2018 - 11:45 AM, said:

On the Is Record Editable for your table you can add code similar to this:
if (values["Status"] == "Inactive")
  return false;
else
  return true;


As far as adding new reocrds, you will need to do something like this on your child list pages:

ListPage Before Process
XVar data = pageObject.getMasterRecord();
if (data != null)
{
string strSQLExists = "select * from dbo.Family where Family_ID='"+data["Family_ID"].ToString()+"' and Status='Inactive'";
XVar rsExists = CommonFunctions.db_query(strSQLExists, null);
XVar data1 = CommonFunctions.db_fetch_array(rsExists);
if(data1)
{
pageObject.setProxyValue("AddRecord", 1);
}
else
{
pageObject.setProxyValue("AddRecord", 0);
}
}


ListPage Javascript onload
var id = "addButton";
var button = $("[id^=" + id + "]");
if (proxy['AddRecord']==1){
button.hide();
}

var id = "inlineAdd";
var button1 = $("[id^=" + id + "]");
if (proxy['AddRecord']==1){
button1.hide();
}


This may not work exactly for you as is, but it should get you going in the right direction.


Thank you very much! As usual, you are a lifesaver jadach!

I modified the first code to look like this,


string strSQLExists = "select * from dbo.Family where Family_ID='"+values["Family_ID"].ToString()+"' and Status='Inactive'";
XVar rsExists = CommonFunctions.db_query(strSQLExists, null);
XVar data1 = CommonFunctions.db_fetch_array(rsExists);
if(data1)
{
  return false;
}
else
{
  return true;
}


I'm leaving it open until tomorrow, hopefully I don't run into issues.
0

#4 User is offline   i.NoLim 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 93
  • Joined: 11-September 17

Posted 08 February 2018 - 04:33 PM

There's is an issue when disabling "Add New" and "Inline Add". If I select an 'Inactive' "Applicant" not only does it disable adding new "Charges" (which is perfect) but it also disables the addition of a new "Family."
I added a few screen shots for clarity.


"Add New" and "Inline Add" for "Family" when an 'Active' "Applicant" is selected.
Posted Image

"Add New" and "Inline Add" are disabled for "Family" when an 'Inactive' "Applicant" is selected.
Posted Image

The following two pictures show the actual "id" is different for those buttons.

Posted Image

Posted Image
0

#5 User is offline   Arkie 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 81
  • Joined: 19-October 15
  • Gender:Male
  • Location:Arkansas

Posted 08 February 2018 - 09:06 PM

Take a look at your line of code:
string strSQLExists = "select * from dbo.Family where Family_ID='"+values["Family_ID"].ToString()+"' and Status='Inactive'";
======
It appears to me that you should be comparing the inactive status to the Applicant ID, not the Family ID. Or perhaps even both IDs. Otherwise your code is doing exactly as it is programmed to do.

I could be reading this wrong, so just go about your biz and ignore this if I am... :)
0

#6 User is offline   i.NoLim 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 93
  • Joined: 11-September 17

Posted 08 February 2018 - 10:59 PM

View PostArkie, on 08 February 2018 - 01:06 PM, said:

Take a look at your line of code:
string strSQLExists = "select * from dbo.Family where Family_ID='"+values["Family_ID"].ToString()+"' and Status='Inactive'";
======
It appears to me that you should be comparing the inactive status to the Applicant ID, not the Family ID. Or perhaps even both IDs. Otherwise your code is doing exactly as it is programmed to do.

I could be reading this wrong, so just go about your biz and ignore this if I am... :)

I do have

string strSQLExists = "select * from dbo.Applicant where Applicant_ID='"+data["Applicant_ID"].ToString()+"' and Status='Inactive'";


but in the Charges' "List page: Before process" event. I cant compare it to Applicant_ID in the Applicant's "List page: Before process" event because the Family table doesn't have a "Applicant_ID" field.
0

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users