about show the date column in the grid (datatype: int)

Questionsabout show the date column in the grid (datatype: int)
Chao Shun Jenq asked 11 years ago

Hello,

I have a "date column" in mysql database, datatype is 'int(10)' . I want to input/show the field in the grid 'yyyy-mm-dd' . How to do it?

Rgds,

4 Answers
Abu Ghufran answered 11 years ago

Method1: You can apply string operations in your SQL (select query) and format that integer date value to yyyy-mm-dd.
Method2: You can use events of grid,

i) on_data_display event is called before rendering data to grid. In that event, you can perform the date formatting action.
ii) as your database has numeric field, you also might need to use on_update & on_insert event, to make yyyy-mm-dd to interger equivalent before insertion.

For both events, refer demos/editing/custom-events.php

Chao Shun Jenq answered 11 years ago

Hello,
in server side event, we can get the field value by$data[params][fieldname].
in on_data_display client side event, how to transform the field value of grid?
Rgds,

Chao Shun Jenq answered 11 years ago

Hello,
in server side event, we can get the field value by $data[params][fieldname].
in on_data_display client side event, how to update the field value of grid?
Rgds,

Abu Ghufran answered 11 years ago

Hello,

For example, you want to capitalize gender field before displayed on grid …

$e["on_data_display"] = array("filter_display", null, true);

function filter_display($data)
{
foreach($data["params"] as &$d)
{
$d["gender"] = strtoupper($d["gender"]);
}
}

Your Answer

7 + 11 =

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?