EasyUI Forum
May 04, 2024, 03:13:44 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: [Solved] Changing the datagrid url based on input radio selection  (Read 17328 times)
kavvson
Newbie
*
Posts: 23


View Profile
« on: October 14, 2014, 07:23:53 AM »

Code:
<div class="adv_filter">
<li>
<input type="radio" name="letter_type" data-custom="Option1" value="0">  Option1
</li><li>
<input type="radio" name="letter_type" data-custom="Option2" value="1" checked="checked">  Option2
</li><li>
<input type="radio" name="letter_type" data-custom="Option3" value="2">  Option3
</li>  
</div>

var url = 'lists.php?ltype='+input_radio_value;

Code:
		$("li").on("click", "input", function() {
$('#dg').datagrid('reload');
// add = $(this).text().val();
globalVar = 'lists.php?ltype='+$(this).val();
});
This onclick function gets the Option1 name only, but I want to get the value thats the first thing. The second this is to override the url with the ?=ltype value, is this even possible? I got in my lists.php $_GET for ltype and everything properly configurated, manually inserting the value works but I want to be able to do it when I select a radio . But basically I have no idea how to accomplish this.

How to get the globalVar isnide

Code:
$('#dg').datagrid({
url : url,


SOLVED AT : http://stackoverflow.com/questions/26387676/passing-a-variable-into-an-other-function-jeasyui
« Last Edit: October 15, 2014, 10:08:43 AM by kavvson » Logged
chrwei
Full Member
***
Posts: 219


View Profile Email
« Reply #1 on: October 14, 2014, 07:58:52 AM »

first problem is that "this" is not going to be the input, off the top of my head you can get that via $("input[name='letter_type']:selected"), or maybe :checked, but that's just jquery stuff.   

then, instead of having the params in the url, define the grid like:

Code:
$('#dg').datagrid({
url: 'lists.php',
queryParams: {
ltype: 'default'
}
});

if you don't want a default then make lists.php return an empty set.  then you can use the 'load' method to change the queryParams and load the new data
Logged
kavvson
Newbie
*
Posts: 23


View Profile
« Reply #2 on: October 14, 2014, 08:06:18 AM »

It sounds logical, but I cant move on I don't know how to do that:(
Logged
chrwei
Full Member
***
Posts: 219


View Profile Email
« Reply #3 on: October 14, 2014, 11:15:49 AM »

it's in the documentation http://www.jeasyui.com/documentation/index.php# under "Query data with some parameters."

Logged
kavvson
Newbie
*
Posts: 23


View Profile
« Reply #4 on: October 14, 2014, 11:24:35 AM »

Code:
$("li").on("click", "input", function() {
$('#dg').datagrid('reload');
// add = $(this).text().val();
globalVar = $(this).val();
});

$('#dg').datagrid({
url: 'lists.php',
queryParams: {
ltype: globalVar
}
});

Ok but can you tell me how to pass the globalVal to query param? And wont it be static? When I press the checkboxe's will it reload the grid - supposingly no.
Logged
chrwei
Full Member
***
Posts: 219


View Profile Email
« Reply #5 on: October 14, 2014, 11:29:43 AM »

did you look at the docs on the load method?  you don't need reload at all.  reload fetches updated data using the same parameters.
Logged
kavvson
Newbie
*
Posts: 23


View Profile
« Reply #6 on: October 14, 2014, 11:47:07 AM »

The link doesn't refere to that. Its index, and there is no under " ". Could you show a example then?
Logged
chrwei
Full Member
***
Posts: 219


View Profile Email
« Reply #7 on: October 14, 2014, 11:59:43 AM »

right from the docs:
Code:
$('#dg').datagrid({
    url:'file.php',
    columns:[[
        {field:'code',title:'Code',width:100},
        {field:'name',title:'Name',width:100},
        {field:'price',title:'Price',width:100,align:'right'}
    ]]
});

$('#dg').datagrid('load', {
    name: 'easyui',
    address: 'ho'
});

Logged
kavvson
Newbie
*
Posts: 23


View Profile
« Reply #8 on: October 14, 2014, 12:26:40 PM »

that's not what I am looking after also;/
Logged
chrwei
Full Member
***
Posts: 219


View Profile Email
« Reply #9 on: October 14, 2014, 12:35:31 PM »

in this case the 'load' call sends name and address query parameters to file.php and reloads the grid data.  it's exactly what you asked for.  sub in your values.
Logged
kavvson
Newbie
*
Posts: 23


View Profile
« Reply #10 on: October 15, 2014, 03:31:52 AM »


Code:
name: 'easyui',
address: 'ho'

what variables does it take / stands for ( name, address ) cause the default values doesn't tell me anything.. ho ? easyui is the grid id?
Logged
chrwei
Full Member
***
Posts: 219


View Profile Email
« Reply #11 on: October 15, 2014, 07:11:37 AM »

no, it's just a text string.  is this more clear?

Code:
$('#dg').datagrid('load', {
    some_param: 'a value',
    another_param: 'another value'
});
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!