Comments (7)
Not sure, I got the problem.
You can specify ajax url doing request to the server in controller methods
http://js-grid.com/docs/#grid-controller
Could you provide an example or more details about your case?
from jsgrid.
Thanks, this is the code
$("#xxx").jsGrid({
width: "100%",
paging: false,
autoload: true,
controller: {
loadData: function() {
var d = $.Deferred();
$.ajax({
url: "/a_list",
dataType: "json"
}).done(function(response) {
d.resolve(response.data);
});
return d.promise();
}
},
fields: [...]
});
After this grid loaded, I want change the ajax url to '/a_list?type=2', and render data to the same $('#xxx') element, is this possible?
from jsgrid.
Yes, it's possible, you can introduce url
variable and change it on ajax done
.
You can put this variable into the closure of self calling function like following:
loadData: (function() {
var url = "/a_list";
return function() {
var d = $.Deferred();
$.ajax({
url: url,
dataType: "json"
}).done(function(response) {
url = "/a_list?type=2";
d.resolve(response.data);
});
return d.promise();
}
})()
Not sure, what you try to achieve, but want to be sure you aware that loadData
accepts pageSize
and pageIndex
parameters if pageLoading = true
See docs http://js-grid.com/docs/#loaddatafilter-promisedataresult
from jsgrid.
What I want to do is a filtering, different datas is loaded by different url, like '/a_list' and '/a_list?type=2', there is a select element in my page, and by different options, I want change the ajax url to get datas.
from jsgrid.
Ok, then define url outside the grid, change it on change event of your select, and call loadData
method.
See following example (actual loading is not happen due to fake urls): http://jsfiddle.net/tabalinas/tjoag1ux/
App = {};
App.loadUrl = "/a_list";
$("#jsgrid").jsGrid({
autoload: true,
width: 200,
controller: {
loadData: function() {
return $.ajax({
type: "GET",
url: App.loadUrl
});
}
},
fields: [
{ type: "text", name: "Name" }
]
});
$("#urlSelect").on("change", function(e) {
App.loadUrl = $(e.target).val();
$("#jsgrid").jsGrid("loadData");
});
Hope it will help.
from jsgrid.
Yes, this is exactly what I want. And thanks for this amazing grid plugin.
from jsgrid.
You are welcome!
Thank you for the feedback, I appreaciate it.
from jsgrid.
Related Issues (20)
- Js grid get cell value cellClick HOT 2
- Need help datetime-local HOT 1
- Is there an official fork that is being heavily used and actively maintained? HOT 1
- Jsgrid select with search box HOT 1
- Detect value of selected value when inserting a new item
- 数据操作时,有没有直接失去焦点保存数据?
- JS grid load data above 5000
- editTemplate on row change error throw $inputFrom was not an function HOT 1
- Multiselect issue.
- Help with a php & Mysql
- Help needed with JsGrid loadData function after I upgraded an old project to .net 7.0 HOT 1
- Help needed with JsGrid loadData function after I upgraded an old project to .net 7.0
- Using autocomplete component with Select2
- How do I validate a DatePicker field? HOT 1
- Loading by Page + Ajax
- how to add password input type in jsgrid HOT 1
- Select type validate required not working in jsgrid
- How to render 1 table instead of 2 tables - First Table(Header, Filter and Insert Row) and Second Table(Item Row) HOT 1
- Load info after save and select option HOT 3
- Manipulating data in a custom field before a row is deleted
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jsgrid.