Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
jqgrid php: how to report an error in dialog
28/04/2011
17:37
Avatar
galli2000
France
New Member
Members
Forum Posts: 2
Member Since:
18/04/2011
sp_UserOfflineSmall Offline

Hello,

I'm currently using the jqGrid php implementation with a manual transaction for adding a record in the grid.

E.g.:

$oper = jqGridUtils::GetParam('oper');
if ($oper == 'add') {

    $grid->trans = false;       // disable the transaction
    try {

        jqGridDB::beginTransaction($conn);

        $reference = jqGridUtils::GetParam('reference');
        $name = jqGridUtils::GetParam('name');
        $brand = jqGridUtils::GetParam('brand');
        $price = jqGridUtils::GetParam('price');
        $total_quantity_left = jqGridUtils::GetParam('total_quantity_left');
        $product = jqGridDB::prepare($conn,
                                     "INSERT INTO product (id, reference, name, brand, price, total_quantity_left) VALUES (NULL,?,?,?,?,?)",
                                     array($reference,
                                           $name,
                                           $brand,
                                           $price,
                                           $total_quantity_left,
                                           )
                                     );
        $stock1 = jqGridDB::prepare($conn,
                                    "INSERT INTO stock (id, shop_id, product_id, quantity) SELECT NULL, 1, (SELECT MAX(id) FROM product), ?",
                                    array(jqGridUtils::GetParam('quantity_shop1'))
                                    );
        $stock2 = jqGridDB::prepare($conn,
                                    "INSERT INTO stock (id, shop_id, product_id, quantity) SELECT NULL, 2, (SELECT MAX(id) FROM product), ?",
                                    array(jqGridUtils::GetParam('quantity_shop2'))
                                    );

        jqGridDB::execute($product);
        jqGridDB::execute($stock1);
        jqGridDB::execute($stock2);
        jqGridDB::commit($conn);

    } catch(Exception $e) {
        jqGridDB::rollBack($conn);
        echo $e->getMessage();
    }

}

This works fine so far.

The problem that I have now is that I want to inform the user if an error occurred during the transaction: typically I'd like to popup a error dialog showing the $e->getMessage(), or the cause of the error

Since the error is detected at the php level, how do I invoke a javascript code portion to achieve this (alert(...) or $.jqgrid.info_dialog(...) I guess)?

Thanks,

jerome

16/05/2011
12:20
Avatar
kobruleht
Member
Members
Forum Posts: 144
Member Since:
05/05/2011
sp_UserOfflineSmall Offline

You shoult set http response code to 4xx

In this case jqGrid reports error.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
52 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information