Get value in same page

QuestionsGet value in same page
Cees asked 10 years ago

my code in list1
$col1["title"] = "title;
$col1["name"] = "name";
$col1["link"] = "#";
$col1["linkoptions"] = "id='doit' onclick=jQuery('#add_list2').click()";
$col1["editoptions"] = array("size"=>30);

and in list2
$getlink=…….?(get value from list1)

$col2["title"] = "title";
$col2["name"] = "name";
$col2["editable"] = true;
$col2["editoptions"] = array("size"=>12, "defaultValue"=>"$getlink");

Thank…

5 Answers
Abu Ghufran answered 10 years ago

For list2, defaultValue will not work. Following code should be used (just for idea)

$grid["edit_options"]["afterShowForm"] = "function() { get_parent_name(); };
$g->set_options($grid);

and in html,

<script>
function get_parent_name()
{
// read value from selected row of list1
var selr = jQuery('#list1').jqGrid('getGridParam','selrow');
var rd = jQuery('#list1').jqGrid('getCell', selr, 'name');

// set in name field of list2
$("#list2 #name").val(rd);
}
</script>

Cees answered 10 years ago

Yes Its Work. I'm using auto add.
My code : http://pastebin.com/0N0NB2nn
But i have trouble, data in add not filtering. Can i filter it like if name in list2 ready auto add error???

Thanks

Abu Ghufran answered 10 years ago

For record already exist check, you need to perform server-validation.
This is currently supported in full version.

If you are already using it, refer demos/editing/server-validation.php for already exist error.

Cees answered 10 years ago

$date=date();
$date1=$_POST[date1];
$date2=$_POST[date2];

if (empty($tgl1) AND empty($tgl1)) { $tgl=date("Y-m-d");
$g2->select_command = "SELECT * FROM data1 WHERE date='$date'";
} else {
$g2->select_command = "SELECT * FROM data1 WHERE date BETWEEN '$date1' AND '$date2'";
}

How refresh grid without refresing page???
thanks again…

Abu Ghufran answered 10 years ago

You can call this JS code to reload grid. (where 'list1' is grid identifier)

jQuery('#list1').trigger("reloadGrid",[{page:1}]);

To use from-to date filter, refer this demo:
http://www.phpgrid.org/demo/demos/search/search-form.php

Code:
http://www.phpgrid.org/demo/demos/search/search-form.phps

Your Answer

14 + 4 =

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?