This topic is locked

One Tap/Click to highlight row and activate duty personnel

5/24/2019 6:33:28 PM
PHPRunner Tips and Tricks
A
acpan author

I have a grid contains 5 freelance hotline personnels.
Grid List:
ID | NAME | Tel
The idea is to alow any active personnel to reassign to other people in the list when he is busy.
Challenge:
I can simply use traditional Edit and select the drop down list and save.

But users are driving on the move, so 1 tap/click and exit is required for safety.
This is done by Click Action on the name field of the Grid:
(Inspiration from https://asprunner.com/forums/topic/25628-highlight-clicked-row-in-a-list-view/pagehlloop%20row%20object%20fromsearch1)
Client Before event:

params["id"] = row.getFieldValue("id");

params["tel"] = row.getFieldValue("tel");

params["name"] = row.getFieldValue("name");
row.setMessage("Changing forwarding number to " + params["name"]);
params["CurrentRowId"] = row.record().closest('tr').attr('id');
//----------------------------------------------------------------------------------------------------------------------------------------------------------

// Get a jQuery reference to the table row and set the background.

//----------------------------------------------------------------------------------------------------------------------------------------------------------
var thisrowid = "#" + params["CurrentRowId"];

var thisrow = $(thisrowid);

thisrow.css('background', 'orange');



Server Code:

$tel = $params["tel"];

$name = $params["name"];

$result["tel"] = $params["tel"];

$result["name"] = $params["name"];
/////////////////////////////////////////////////////////////////////////////////

// Details below are not shown here as we just want to show how to tap and switch.

// 1. SQL Update another DB Table to change the forwarding number

// 2. Once updated, send a HTTP Post to our notification server to inform the new active person via SMS and Call.

// Details above are not shown here as we just want to show how to tap and switch.

/////////////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------------------------------------------------------------------------------------------

// Pass the last row id along to the client after event

//----------------------------------------------------------------------------------------------------------------------------------------------------------

if ($_SESSION["CurrentRowId"] == null)

{

$result["LastRowId"] = "";

}

else

{

$result["LastRowId"] = $_SESSION["CurrentRowId"];

}
// Save the current row id

$_SESSION["CurrentRowId"] = $params["CurrentRowId"];


Client After Event:

//--------------------------------------------------------------------------------------------------------------------

// Retrive the previous row ID with active personnel and unhighlight it

//--------------------------------------------------------------------------------------------------------------------

var lastrowid = "#" + result["LastRowId"];

var lastrow = $(lastrowid);

lastrow.css('background', 'white');

location.reload();


That's all.

P
psciga 8/24/2020

many thanks for sharing!!

Peter