Checkbox select but not multi select

QuestionsCheckbox select but not multi select
jim varrone asked 2 weeks ago

I am using the code below but here are my problems/questions:

  • I need to be able to select a row by checkbox, but not more than one row. If I turn off multi-select I get no check boxes.
  • Once I select a row by checkbox, how do I query the value of a particular cell in the row to use to sen to another php module?

$grid[“multiselect”] = true;
$grid[“beforeSelectRow”] = “function(rowid, e) { return $(e.target).is(‘input[type=checkbox]’); }”;

 

3 Answers
jim varrone answered 2 weeks ago

P.S. I may be going about this the wrong way. I need to select a row, but since I’m color formatting the rows, I can’t see any indication that I’ve selected a row.So I thought that the checkbox would be an alternative. I’m using this code to color the rows:

$col["column"] = "status";
$col["op"] = "eq";
$col["value"] = "InProcess";
$col["css"] = "'background-color':'yellow', 'color':'black'";
$col_conditions[] = $col;

$col["column"] = "status";
$col["op"] = "eq";
$col["value"] = "VisitReady";
$col["css"] = "'background-color':'lightgreen', 'color':'black'";
$col_conditions[] = $col;

$col["column"] = "status";
$col["op"] = "eq";
$col["value"] = "VisitCompleted";
$col["css"] = "'background-color':'springgreen', 'color':'black'";
$col_conditions[] = $col;
Adrian answered 2 weeks ago

Hi and Happy New Year!

I use something like:
background: repeating-linear-gradient(120deg, #63C384, #63C384 1px, transparent 1px, transparent 2px);

Best regards!

Abu Ghufran Staff answered 1 day ago

Hello,

To have a checkbox with one selection at a time, first enable multiselect:true

$grid["multiselect"] = true;
$grid["multiboxonly"] = true; // only allow selection using checkbox (not with row click)

Then you can try following:

$grid["beforeSelectRow"] = "function(rowid, e) { if ( jQuery('#list1').jqGrid('getGridParam','selarrrow') != rowid) jQuery('#list1').jqGrid('resetSelection'); return true; }";

OR

$grid["beforeSelectRow"] = "function(rowid, e) { return $(e.target).is('input[type=checkbox]'); }";

Finally, this $grid will be passed to set_options along with your other grid options.

$g->set_options($opt);

Now to pass the selected row to another page, e.g. on button click

<button onclick="pass_selected()">Pass</button>
<script>
function pass_selected() {
var ids = jQuery('#list1').jqGrid('getGridParam','selarrrow').join(',');
window.open('your-page.php?ids='+ids);
}
</script>

Let me know if you have any questions.

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Your Answer

7 + 19 =

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?