New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BootGrid Command Buttons, Custom button bootstrap #94
Comments
You should look at this example on the homepage of the plugin: http://www.jquery-bootgrid.com/Examples#command-buttons |
@ksidibe Do you mean in this part of the JS formatters: { |
Yes. Also, remember to define the header of the column where you want to have the buttons like this: < th data-column-id="commands" data-formatter="commands" data-sortable="false" >Commands< /th> . Finally, chain the onload handler as follows: |
@ksidibe @rstaib don't appears... I new of using bootgrid I have this: < th data-column-id="commands" data-formatter="commands" data-sortable="false" data-header-css-class="customerColumn">commands < /th > < td > In the JS: var grid = $("#grid").bootgrid({ |
You are instantiating bootgrid on the same element twice. Try deleting data-toggle="bootgrid" data-url="/currencies/" from the html table definition. |
@ksidibe if I remove data-toggle="bootgrid" don't show me the records that I get from the database and show me the message "No results found" |
When I had that problem, it was because of the route definition. I was using url:"/mysuperurl/". Then I changed it to url:"/mysuperurl" (without the trailing /) and that worked. |
@rstaib @ksidibe Doesn't work, that frustrating... I do a application in ASP.NET MVC 4, my code is like this: < div class="container-fluid">
< /div> JS: |
There are two issues I can see with you code. First, when using bootgrid, you do not include the tags in you table. So, all you need is:
2- Whatever url you are referring to when instantiating the bootgring class, that url must return json. NO HTML. I see that in your csHtml, you are iterating through your model an manually creating the elements. You can't do that. Here's what I recommend. then add this to the method handling the request: public ActionResult SomeActionMethod()
{
.
.
.
.
.
if (Request.IsAjaxRequest())
{
var jsonSerialiser = new JavaScriptSerializer();
var json = jsonSerialiser.Serialize(myListOfModels);
return json;
}
.
.
.
.
.
} Option B: create a completely separate route that only returns JSON, and call that URL instead |
By the way, one small update. You should set the json key rows to the array of models. You should also set rowCount to modelList.count() and finally properly set the value of total. |
@ksidibe In my controller have this method with the option A public ActionResult CurrencyIndex()
how in the view get the values model without iterating the model and manually creating the elements |
When servicing a request from bootgrid, you are not supposed to return a view. You are supposed to return a JSON. formatters: {
"commands": function(column, row)
{
return "<button type=\"button\" class=\"btn btn-xs btn-default command-edit\" data-row-id=\"" + row.id + "\"><span class=\"fa fa-pencil\"></span></button> " +
"<button type=\"button\" class=\"btn btn-xs btn-default command-delete\" data-row-id=\"" + row.id + "\"><span class=\"fa fa-trash-o\"></span></button>";
}
} Finally, here's what I would do if I were you. Create a URL that returns this static JSON object: {
"current": 1,
"rowCount": 10,
"rows": [
{
"id": 19,
"sender": "123@test.de",
"received": "2014-05-30T22:15:00"
},
{
"id": 14,
"sender": "123@test.de",
"received": "2014-05-30T20:15:00"
}
],
"total": 1123
} Make the table work with that static dummy data. Then you can rewrite your controller properly. |
@ksidibe Achieve That worked with static dummy data, it is advance. now I did this method public ActionResult listCurrencyJson() { And in the JS call that method var grid = $("#grid").bootgrid({ But when run, give a error, Unhandled exception at line 565, column 9 in http://localhost:58969 /Scripts/jquery.bootgrid.js 0x800a138f - JavaScript runtime error: Unable to get property 'length' of undefined or null reference function renderRows(rows) , show me the parameters "rows" is "undefined" |
Like I mentioned in my previous post, the keys of the should include "rows", "current", "rowCount". Your json does not contain thoses keys. That's what the error is saying. public ActionResult listCurrencyJson() {
var json = "";
if (Request.IsAjaxRequest())
{
var keyValues = new Dictionary<string, Currency>
{
{ "rows", context.currency.ToList()},
{ "rowCount", context.currency.count() },
{"current", Request.params.getValue("current")}
};
JavaScriptSerializer js = new JavaScriptSerializer();
string json = js.Serialize(keyValues);
return Json(json, JsonRequestBehavior.AllowGet);
}
return Json(json, JsonRequestBehavior.AllowGet);
} Finally, since the issue you are having is not related to the bootgrid plugin, and in order to keep this forrum as useful as possible, I recommend that you post a question on Stackoverflow. You can post the link here and I can try an help you there instead. |
@ksidibe I have error with the dictionary but I open a post in the Stackoverflow for your help |
@ksidibe when I serializer the keyValues in the row have DateTime Column and show me in the gird /Date(1422943200000)/ and not the normal format 2/03/2015 12.00.00 PM |
Can you post the skeleton of the Currency class? |
@ksidibe in the currency class don't have the column of the database that is a DateTime. I get the data of that specific column directly of the context of entity framework |
Let's step back for a minute. What data are you trying to display? |
@ksidibe I get data from the context of entity framework, table currency. I want to display the date of the column "CreateDate" that type of that column is DateTime in keyValues get this result and show me a normal format |
@pabloso18 Please ask here only questions regarding bootgrid not ASP.Net MVC specific questions and don't mixup too many questions so it is easier for people to help you. For questions regarding ASP.Net MVC please go to Stackoverflow. Thanks! @ksidibe Thanks for helping @pabloso18 |
how to make entire row using font-weight:bold ????????? i tired to get search... remember just one row.??? |
How can I put custom button (Style Bootstrap) in the row "Command"
< th data-column-id="commands" data-formatter="commands" data-sortable="false">Commands < /th >
< td class="text-left">
< button type="button" class="btn btn-default" aria-label="Left Align" >
< span class="glyphicon glyphicon-align-left" aria-hidden="true" >< /span >
< /button >
< /td >
When Run the Application don't show me the button in that row. any suggestion?
The text was updated successfully, but these errors were encountered: