Default order in view ind ail mode with multirow selection

Talk about Sorting & Paging problems, issues etc.

Moderator: alexandrleonenko

mbreitkreuz1
Senior
Senior
Posts: 47
Joined: Jan 21st, '10, 15:47

Default order in view ind ail mode with multirow selection

Postby mbreitkreuz1 » May 20th, '10, 14:14

Hello,

I have a problem with default order.

Here an example of one of many of my table definitions:
I defined a table as follows:

$sql=" SELECT
massn_massnahmen_politikfelder.id,
massn_massnahmen_politikfelder.id_politikfeld,
pf_oberste_politikfelder.politikfeld,
massn_massnahmen_politikfelder.massn_komplex,
massn_massnahmen_politikfelder.bez_massn_komplex,
massn_massnahmen_politikfelder.zweck_massn_komplex,
massn_massnahmen_politikfelder.infobasis,
massn_massnahmen_politikfelder.fundort_infobasis,
massn_massnahmen_politikfelder.zust_massn_komplex,
massn_massnahmen_politikfelder.date_beschluss_datum,
DATE_FORMAT(massn_massnahmen_politikfelder.date_beschluss_datum, '%d.%m.%Y') as date_beschluss_datum2
FROM massn_massnahmen_politikfelder
INNER JOIN pf_oberste_politikfelder
ON (massn_massnahmen_politikfelder.id_politikfeld = pf_oberste_politikfelder.id)";

----------------------------------------------------------------

Then I defined the default order:

$default_order_field = "politikfeld, massn_komplex";

I active multirow functionality.

In view mode i's ok. But if I selected more then 2 records and choose the details mode, an error occurs, because an order by politikfeld failed (politikfeld
is a field in another table (pf_oberste_politikfelder).

Now my question: is it possible to set $default_order_field different in view and detail mode? Ok, in details mode I can only order by massn_komplex.
But it where nice to set the complete order by potitikfeld, mass_komplex in view mode.
If tried this in the following way:

$mode = (isset($_GET['ksm_mode'])) ? $_GET['ksm_mode'] : "";

if ($mode!="details"){
$default_order_field = "politikfeld, massn_komplex";
}else{
$default_order_field = "massn_komplex";
}

But this has no effect. I think $default_order_field is set only one time.
Ok I can write a customized template, but then I must change a lot of code because I have over 50 tables to handle and many of them have foreign keys.
Do you have any hints what to do ?

Thank you
and best regrdas,
mbreitkreuz

mbreitkreuz1
Senior
Senior
Posts: 47
Joined: Jan 21st, '10, 15:47

Re: Default order in view ind ail mode with multirow selection

Postby mbreitkreuz1 » May 20th, '10, 14:18

Oh excuse me, some wrong characters in subject:

Default order in view and in detail mode with multirow selection.

regards,
mbreitkreuz

administrator
Site Admin
Site Admin
Posts: 6004
Joined: Jan 7th, '09, 23:18
Contact:

Re: Default order in view ind ail mode with multirow selection

Postby administrator » May 23rd, '10, 15:12

1. You are right, $default_order_field is set only one time.
2. Sometimes, you cannot use default order for details mode, because tables in View mode and Details mode may be different.

mbreitkreuz1
Senior
Senior
Posts: 47
Joined: Jan 21st, '10, 15:47

Re: Default order in view ind ail mode with multirow selection

Postby mbreitkreuz1 » May 24th, '10, 21:09

Hello,

thank you for your reply, but I have solved this issue as follows:

1. I defined a class var my_start_order.

2. I changed this:

function DataSource($db_handl, $sql = "", $start_order = "", $start_order_type = ""){
$req_mode = $this->GetVariable('mode');

//****************************************************
// change - begin
//****************************************************
$this->my_start_order = $start_order;
//****************************************************
// change - end
//****************************************************


3. At last this:

function Bind($show = true){
$this->SetInterfaceLang();
$this->SetCommonJavaScript();

// for the case when safeMode == true
$this->rids = explode("-", $this->rid);
if(count($this->rids) > 1){
$this->multiRows = count($this->rids);
}
if(count($this->rids) <= 1) $this->rid = $this->DecodeParameter($this->GetVariable('rid'));
$req_mode = $this->GetVariable('mode');
$req_new = $this->GetVariable('new');
$req_p = $this->GetVariable('p');
$req_page_size = $this->GetVariable('page_size');

//****************************************************
// change - begin
//***************************************************
if ( $req_mode == "details" ) {
$req_sort_field = $this->my_start_order;
}else{
$req_sort_field = $this->GetVariable('sort_field');
}
//$req_sort_field = $this->GetVariable('sort_field');
//****************************************************
// change - end
//****************************************************


4. Now I can decide in my code:

$mode = (isset($_GET['ksm_mode'])) ? $_GET['ksm_mode'] : ""; (ksm_ is my unique prefix)
if ( $mode != "details" ] {
$default_order_field = "......"; //order fields in view mode
}else{
//order fields in detail mode
}


I don't know if there is another better way, but it works!!

Best regards,
mbreitkreuz


Return to “Settings: Sorting & Paging”