Exporting all records from Shield UI Grid - grid
I am trying to export all data from a data grid. The shield UI example demo does export all records so I know it can be done! When I do it, it only exports the current pages data!
Java code snippets:
remote: {
read: {
type: "POST",
url: "/portals/ajax"
}
}
});
$("#manageportalsgrid").shieldGrid({
dataSource: portals,
sorting: {
multiple: true
},
selection: {
type: "row",
multiple: true,
toggle: false
},
filtering: {
enabled: true
},
paging: true,
columns: [
{ field: "portalID", width: "130px", title: "Portal ID" },
{ field: "overx", width: "130px", title: "Overworld X" },
{ field: "overy", width: "130px", title: "Overworld Y" },
{ field: "overz", width: "130px", title: "Overworld Z" },
{ field: "netherx", width: "130px", title: "Nether X" },
{ field: "nethery", width: "130px", title: "Nether Y" },
{ field: "netherz", width: "130px", title: "Nether Z" },
{ field: "portalowner", width: "130px", title: "Portal Owner"},
{ field: "description", width: "130px", title: 'Portal Description'},
{
field:"actions",
width: "200px",
title:"Actions",
columnTemplate: $("#portalEditTemplate").html() + $("#portalDeleteTemplate").html()
}
],
toolbar: [
{
buttons: [
{
commandName: "csv",
caption: '<span class="sui-sprite sui-grid-icon-export-csv"></span> <span class="sui-grid-button-text">Export to CSV</span>'
}
]
}
],
exportOptions: {
proxy: "/attachments/save",
csv: {
fileName: "Viikis Community Server portals " + getMonthforFile(),
dataSource: portals,
readDataSource: true
}
}
});
function getMonthforFile(){
var months = ['January','February','March','April','May','June','July','August','September','October','November','December'];
var now = new Date();
var thisMonth = months[now.getMonth()];
var year = now.getFullYear();
var monthyear = thisMonth +' ' + year;
return monthyear;
}
the datasource calls a php script that generates the data source, which outputs:
[{"portalID":"2","netherx":"63","nethery":"32","netherz":"-69","overx":"500","overy":"59","overz":"-550","description":"Carley_Guys Base","owner":"2","userID":"2","portalowner":"carley_guy"},{"portalID":"3","netherx":"66","nethery":"32","netherz":"112","overx":"531","overy":"57","overz":"892","description":"Krons Portal","owner":"3","userID":"3","portalowner":"Kron"},{"portalID":"4","netherx":"-19","nethery":"32","netherz":"-79","overx":"-150","overy":"64","overz":"-629","description":"Rosysian's Home","owner":"4","userID":"4","portalowner":"Rosysian"},{"portalID":"5","netherx":"-22","nethery":"32","netherz":"97","overx":"-178","overy":"59","overz":"776","description":"Budmeister's Portal","owner":"5","userID":"5","portalowner":"Budmeister91"},{"portalID":"6","netherx":"100","nethery":"32","netherz":"51","overx":"796","overy":"53","overz":"406","description":"Tired_Luvs Portal","owner":"6","userID":"6","portalowner":"Tired_Luvs"},{"portalID":"7","netherx":"47","nethery":"56","netherz":"-68","overx":"378","overy":"53","overz":"-547","description":"","owner":"7","userID":"7","portalowner":"EdenShieldex"},{"portalID":"9","netherx":"50","nethery":"32","netherz":"11","overx":"401","overy":"80","overz":"89","description":"","owner":"10","userID":"10","portalowner":"thewookie0"},{"portalID":"10","netherx":"165","nethery":"35","netherz":"139","overx":"1317","overy":"63","overz":"1113","description":"Viikis Jungle Portal","owner":"8","userID":"8","portalowner":"Viiki"},{"portalID":"11","netherx":"333","nethery":"32","netherz":"331","overx":"2661","overy":"68","overz":"2650","description":"Dummy Portal Beths Adventure","owner":"6","userID":"6","portalowner":"Tired_Luvs"},{"portalID":"12","netherx":"-32","nethery":"32","netherz":"43","overx":"-256","overy":"81","overz":"340","description":"egidasha's portal","owner":"31","userID":"31","portalowner":"egidasha"},{"portalID":"13","netherx":"-58","nethery":"34","netherz":"-7","overx":"-464","overy":"71","overz":"-52","description":"Psylences Portal","owner":"23","userID":"23","portalowner":"Psylence33"},{"portalID":"14","netherx":"-33","nethery":"32","netherz":"25","overx":"-262","overy":"77","overz":"199","description":"Viikis Portal Near Spawn","owner":"8","userID":"8","portalowner":"Viiki"},{"portalID":"15","netherx":"-41","nethery":"32","netherz":"26","overx":"-330","overy":"64","overz":"206","description":"Pengdonuts Portal","owner":"19","userID":"19","portalowner":"PengDonut"},{"portalID":"16","netherx":"-24","nethery":"32","netherz":"-112","overx":"-193","overy":"63","overz":"-898","description":"RocWolfes Portal","owner":"14","userID":"14","portalowner":"RocWolfe"},{"portalID":"17","netherx":"32","nethery":"32","netherz":"-133","overx":"256","overy":"59","overz":"-1066","description":"MysteryMuffins' Portal","owner":"11","userID":"11","portalowner":"meepymuffins"},{"portalID":"18","netherx":"-24","nethery":"32","netherz":"83","overx":"-193","overy":"105","overz":"663","description":"Moi33","owner":"25","userID":"25","portalowner":"MoiXtra"},{"portalID":"19","netherx":"-56","nethery":"32","netherz":"21","overx":"-450","overy":"51","overz":"166","description":"Jerv's Portal","owner":"21","userID":"21","portalowner":"jervi_servi"},{"portalID":"20","netherx":"19","nethery":"32","netherz":"12","overx":"154","overy":"66","overz":"98","description":"Br3admakesufat's Portal","owner":"24","userID":"24","portalowner":"BR3ADMAKESUFAT"},{"portalID":"22","netherx":"96","nethery":"32","netherz":"113","overx":"771","overy":"65","overz":"906","description":"BentlyEU's Portal","owner":"26","userID":"26","portalowner":"bentley"},{"portalID":"23","netherx":"60","nethery":"32","netherz":"78","overx":"483","overy":"63","overz":"621","description":"hozbombs Portal","owner":"29","userID":"29","portalowner":"hozbomb"},{"portalID":"24","netherx":"-8","nethery":"32","netherz":"5","overx":"-64","overy":"96","overz":"36","description":"sushis Portal","owner":"27","userID":"27","portalowner":"thereal_sushi"},{"portalID":"25","netherx":"-64","nethery":"32","netherz":"68","overx":"-509","overy":"72","overz":"547","description":"ikxrleys Portal","owner":"32","userID":"32","portalowner":"ikxrley"},{"portalID":"26","netherx":"-67","nethery":"32","netherz":"-6","overx":"-532","overy":"64","overz":"-46","description":"wizard1011's Portal","owner":"30","userID":"30","portalowner":"superswag3211"},{"portalID":"27","netherx":"-50","nethery":"32","netherz":"41","overx":"-400","overy":"66","overz":"324","description":"WW__WW's Portal","owner":"29","userID":"29","portalowner":"hozbomb"},{"portalID":"28","netherx":"-44","nethery":"32","netherz":"6","overx":"-352","overy":"67","overz":"51","description":"hippert02s Portal","owner":"33","userID":"33","portalowner":"hippert"},{"portalID":"29","netherx":"67","nethery":"32","netherz":"50","overx":"535","overy":"65","overz":"398","description":"FaithfulSO3s Portal","owner":"28","userID":"28","portalowner":"ixfaithful"},{"portalID":"30","netherx":"156","nethery":"32","netherz":"143","overx":"1245","overy":"11","overz":"1141","description":"Bud's Jungle Portal","owner":"5","userID":"5","portalowner":"Budmeister91"},{"portalID":"31","netherx":"192","nethery":"32","netherz":"-252","overx":"1532","overy":"65","overz":"-2013","description":"VirusBB8's base","owner":"17","userID":"17","portalowner":"VirusBB8"},{"portalID":"32","netherx":"-150","nethery":"32","netherz":"-151","overx":"-1197","overy":"22","overz":"-1205","description":"End Portal Room","owner":"3","userID":"3","portalowner":"Kron"},{"portalID":"34","netherx":"244","nethery":"32","netherz":"249","overx":"1950","overy":"68","overz":"1993","description":"NorwegianGreaser Home","owner":"22","userID":"22","portalowner":"NorwegianGreaser"},{"portalID":"35","netherx":"-22","nethery":"15","netherz":"54","overx":"-172","overy":"75","overz":"430","description":"LordPapi_s Portal","owner":"12","userID":"12","portalowner":"Lordpapi_"},{"portalID":"36","netherx":"642","nethery":"32","netherz":"633","overx":"5133","overy":"70","overz":"5067","description":"Middle of the sea","owner":"22","userID":"22","portalowner":"NorwegianGreaser"},{"portalID":"37","netherx":"548","nethery":"32","netherz":"272","overx":"4385","overy":"70","overz":"2172","description":"Desert into soul sand valley","owner":"35","userID":"35","portalowner":"iamtehnub"},{"portalID":"38","netherx":"140","nethery":"32","netherz":"56","overx":"1123","overy":"70","overz":"450","description":"Mountain biome port","owner":"35","userID":"35","portalowner":"iamtehnub"},{"portalID":"39","netherx":"405","nethery":"32","netherz":"219","overx":"3237","overy":"65","overz":"1753","description":"","owner":"22","userID":"22","portalowner":"NorwegianGreaser"},{"portalID":"43","netherx":"-110","nethery":"32","netherz":"-130","overx":"-880","overy":"97","overz":"-1040","description":"TmacMusic's Base","owner":"1","userID":"1","portalowner":"TmacMusic"}]
Here is the manage portal view code
<?php require APPROOT . '/views/inc/header.php'; ?>
<h1><?php echo $data['title']; ?></h1>
<div id="adminFlex">
<?php require APPROOT . '/views/inc/navadmin.php'; ?>
<div id="adminDashBoard" class="dashboard">
<script type="text/x-shield-template" id="portalEditTemplate">
<a class="btn btn-info" href="/portals/edit/{portalID}">Edit</a>
</script>
<script type="text/x-shield-template" id="portalDeleteTemplate">
<button type="button" class="btn btn-danger" id="delete" data-target="#confirmDeletePortal" data-toggle="modal" data-portalid="{portalID}">Delete</button>
</script>
<div class="row">
<div id="manageportalsgrid" class="center">
</div>
<button class="btn-info" onclick="refreshManagePortalData()">Refresh Portals</button>
<button class="btn-danger" data-target="#confirmDeleteAllPortals" data-toggle="modal">Delete All Portals</button>
</div>
<!-- Delete portal by ID Modal -->
<div class="modal fade" id="confirmDeletePortal" tabindex="-1" role="dialog" aria-labelledby="confirmDeletePortalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="confirmDeletePortalLabel">Delete portal?</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<p>Are you sure you want to delete this portal?
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">No</button>
<form action="<?php echo URLROOT; ?>portals/delete/" method=post>
<input type="hidden" id="delportalID" name="portalID" value="">
<input type="submit" class="btn btn-danger" name="action" value="delete"/>
</form>
</div>
</div>
</div>
</div>
<!-- Delete All Portals Modal -->
<div class="modal fade" id="confirmDeleteAllPortals" tabindex="-1" role="dialog" aria-labelledby="confirmDeleteAllPortalsLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="confirmDeleteAllPortalsModalLabel">Delete All Portals?</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<p>Are you sure you want to delete all the portals?
</div>
<div class="modal-footer">
<form action="<?php echo URLROOT; ?>portals/clear/" method=post>
<button type="button" class="btn btn-secondary" data-dismiss="modal">No</button>
<input type="submit" name="yes" value="yes" class="btn btn-primary"/>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
<?php require APPROOT . '/views/inc/footer.php'; ?>
My issue is that it only ever exports the current page, not the entire record set. The documentation says you should set the readDataSource to true for it to do so, but it's not working.
Thanks in advance for any help.
I think the readDataSource option is ignored if the datasources and or their variables are Identical. I duplicated the the portals datasource and made the copy exportportals like so:
var portals = new shield.DataSource({
remote: {
read: {
type: "POST",
url: "/portals/ajax"
}
}
});
var exportportals = new shield.DataSource({
remote: {
read: {
type: "POST",
url: "/portals/ajax"
}
}
});
Then I changed the dataSources for the grid and the export dataSources respectively:
$("#manageportalsgrid").shieldGrid({
dataSource: portals,
sorting: {
multiple: true
},
selection: {
type: "row",
multiple: true,
toggle: false
},
filtering: {
enabled: true
},
paging: true,
columns: [
{ field: "portalID", width: "130px", title: "Portal ID" },
{ field: "overx", width: "130px", title: "Overworld X" },
{ field: "overy", width: "130px", title: "Overworld Y" },
{ field: "overz", width: "130px", title: "Overworld Z" },
{ field: "netherx", width: "130px", title: "Nether X" },
{ field: "nethery", width: "130px", title: "Nether Y" },
{ field: "netherz", width: "130px", title: "Nether Z" },
{ field: "portalowner", width: "130px", title: "Portal Owner"},
{ field: "description", width: "130px", title: 'Portal Description'},
{
field:"actions",
width: "200px",
title:"Actions",
columnTemplate: $("#portalEditTemplate").html() + $("#portalDeleteTemplate").html()
}
],
toolbar: [
{
buttons: [
{
commandName: "csv",
caption: '<span class="sui-sprite sui-grid-icon-export-csv"></span> <span class="sui-grid-button-text">Export to CSV</span>'
}
]
}
],
exportOptions: {
proxy: "/attachments/save",
csv: {
fileName: "Viikis Community Server portals " + getMonthforFile(),
dataSource: exportportals,
readDataSource: true
}
}
});
Now the Grid shows with the pagination and when exporting all the records get exported!
Related
Remove recipes from emit
I have a Recipe project and I want to delete those recipes through a button. I have 3 components: RecipesCar: Who prints the recipes RecipesList: Who load de list App: Who has the recipes object. I'm trying to delete the recipes but at this moment is not working. I can capture the events but is not working cause the recipes are not deleting. Here my code: RecipesCard: <template> <div class="recipe" :class="recipe.featured && 'featured'"> <button class="delete-recipe"> <img src="../assets/delete-button.svg" alt="Delete recipe" #click="deleteRecipe(this.recipe.id)" /> </button> <h2 class="recipe-title">{{ recipe.title }}</h2> <div class="recipe-image"> <img :src="recipe.imageUrl" /> </div> <div class="recipe-info"> <div class="recipe-info-item"> <span class="recipe-info-label">Servings:</span> <span class="recipe-info-value">{{ recipe.servings }}</span> </div> <div class="recipe-info-item"> <span class="recipe-info-label">Time:</span> <span class="recipe-info-value">{{ recipe.time }}</span> </div> <div class="recipe-info-item"> <span class="recipe-info-label">Difficulty:</span> <span class="recipe-info-value">{{ recipe.difficulty }}</span> </div> </div> <div class="recipe-ingredients"> <h3 class="recipe-ingredients-title">Ingredients</h3> <ul class="recipe-ingredients-list"> <li v-for="ingredient in recipe.ingredients" :key="ingredient"> {{ ingredient }} </li> </ul> </div> <div class="recipe-directions"> <h3 class="recipe-directions-title">Directions</h3> <ol class="recipe-directions-list"> <li v-for="direction in recipe.directions" :key="direction"> {{ direction }} </li> </ol> </div> </div> </template> <script> import { defineComponent } from "vue"; export default defineComponent({ name: "RecipeCard", props: { recipe: { type: Object, required: true, }, }, methods: { deleteRecipe() { console.log(this.recipe.id); this.$emit("my-event-delete", this.recipe.id); }, }, }); </script> RecipesList: <template> <div id="recipe-list" class="recipe-list"> <div v-for="(recipe, id) in recipeList" :key="recipe.id"> <recipe :recipe="recipe" #my-event-delete="deleteRecipe(id)" /> </div> </div> </template> <script> import { defineComponent } from "vue"; import Recipe from "./RecipeCard.vue"; export default defineComponent({ name: "RecipeList", props: { recipeList: { type: Array, required: true, }, }, components: { Recipe }, methods: { deleteRecipe(id) { console.log("Componente borrado " + id); }, }, }); </script> App <template> <div id="app"> <div class="header"> <img class="logo" alt="UOC logo" src="./assets/uoc-logo.png" /> <div class="app-name">Recipe book</div> </div> <search-bar /> <recipe-list :recipeList="recipeList" #deleteRecipe="deleteRecipe" /> <recipe-form v-if="showModal" /> </div> </template> <script> import RecipeList from "./components/RecipeList.vue"; import RecipeForm from "./components/RecipeForm.vue"; import SearchBar from "./components/SearchBar.vue"; import { defineComponent } from "vue"; export default defineComponent({ name: "App", components: { RecipeList: RecipeList, RecipeForm, SearchBar, }, data: () => ({ recipeList: [ { id: 1, servings: 4, time: "30m", difficulty: "Easy", title: "Spaghetti", ingredients: ["noodles", "tomato sauce", "cheese"], directions: ["boil noodles", "cook noodles", "eat noodles"], imageUrl: "https://imagesvc.meredithcorp.io/v3/mm/image?q=60&c=sc&poi=face&w=2000&h=1000&url=https%3A%2F%2Fstatic.onecms.io%2Fwp-content%2Fuploads%2Fsites%2F21%2F2018%2F02%2F14%2Frecetas-4115-spaghetti-boloesa-facil-2000.jpg", }, { id: 2, servings: 2, time: "15m", difficulty: "Medium", title: "Pizza", ingredients: ["dough", "tomato sauce", "cheese"], directions: ["boil dough", "cook dough", "eat pizza"], imageUrl: "https://www.saborusa.com/wp-content/uploads/2019/10/Animate-a-disfrutar-una-deliciosa-pizza-de-salchicha-Foto-destacada.png", featured: true, }, { id: 3, servings: 6, time: "1h", difficulty: "Hard", title: "Salad", ingredients: ["lettuce", "tomato", "cheese"], directions: ["cut lettuce", "cut tomato", "cut cheese"], imageUrl: "https://www.unileverfoodsolutions.es/dam/global-ufs/mcos/SPAIN/calcmenu/recipes/ES-recipes/In-Development/american-bbq-beef-salad/main-header.jpg", }, ], showModal: false, }), methods: { deleteRecipe() { console.log("this.id"); this.recipeList.splice(this.recipeList.indexOf(this.id), 1); }, }, }); </script> Can you help me plz? Thanks I tried to make and 'emit' but the emit stops on RecipeList.
How to validate dynamically generated fields with bootstrap validator. `Error Cannot read property 'apply' of undefined`
I have my form here that contains the fields that i want validated. Currently there is one Name of Recipient field but the user can click the addKit button which will dynamically generate new input fields for the user to fill out. The validation library i am using validates the fields by matching the input field name to the bootstrapValidator fields list. In this case for instance, it will look at <input type="text" style="margin:0px 0px 7.5px 0px;" class="form-control" name="kits[COZ1][1][name]" value=""> and match the name kits[COZ1][1][name] to the field name in the fields list in the javascript. Now as there are more inputs generated the name will change dynamically, the next input name will be kits[COZ1][2][name] and so on... I am using the addField method to add the field dynamically but run into an error. What am i doing wrong here? <form class="well form-horizontal" action="" method="post" id="order"> <fieldset> <legend><b>Requestor</b></legend> <div class="form-group"> <label class="col-md-4 control-label">Requestor Name</label> <div class="col-md-4 inputGroupContainer"> <div class="input-group"> <span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span> <input name="requestorName" placeholder="Requestor Name" class="form-control" id="requestorName" type="text" required> </div> </div> </div> <div class="form-group"> <label class="col-md-4 control-label">Requestor Email</label> <div class="col-md-4 inputGroupContainer"> <div class="input-group"> <span class="input-group-addon"><i class="glyphicon glyphicon-envelope"></i></span> <input name="requestorEmail" placeholder="Requestor Email" class="form-control" id="requestorEmail" type="text" required> </div> </div> </div> <div class="form-group"> <label class="col-md-4 control-label">Requestor Broker Dealer</label> <div class="col-md-4 inputGroupContainer"> <div class="input-group"> <span class="input-group-addon"><i class="glyphicon glyphicon-home"></i></span> <input name="firm" placeholder="Firm Name" class="form-control" id="firm" type="text" required> </div> </div> </div> <legend><b>Kit Details</b></legend> <?php foreach($kit_types as $type => $description): ?> <div class="form-group"> <label class="col-md-4 control-label"><?php echo $description; ?></label> <div class="col-md-4 inputGroupContainer"> <div class="input-group"> <span class="input-group-addon"><i class="glyphicon glyphicon-file"></i></span> <input class="form-control" size="10" value="1" placeholder="Quantity" name="quantity_<?php echo $type; ?>" id="quantity_<?php echo $type; ?>" type="text" required /> </div> <div class="invalid-feedback"> Please enter the Quantity of Kits Needed </div> <button style="margin:15px 15px 0px 0px;" class="kitQuantityUpdate btn btn-primary btn-sm" id="update_<?php echo $type; ?>" type="button" value="Show" />Show <span class="glyphicon glyphicon-refresh"></span></button> <button style="margin:15px 15px 0px 0px;" class="kitAdd btn btn-warning btn-sm" id="add_<?php echo $type; ?>" type="button" value="Add Kit" />Add Kit <span class="glyphicon glyphicon-plus-sign"></span></button> </div> <div class="kitDetail" id="kitDetail_<?php echo $type; ?>"> </div> </div> <div class="form-group"> <label class="col-md-4 control-label">Name of Recipient</label> <div class="col-md-4 inputGroupContainer"> <div class="input-group"> <div id="kitList"> <div class="detailList" id="detail_<?php echo $type; ?>"> <input type="text" style="margin:0px 0px 7.5px 0px;" class="form-control" name="kits[COZ1][1][name]" value=""> </div> </div> </div></div> </div> <?php endforeach; ?> <!--<legend><b>Kit Delivery</b></legend>--> <div class="form-group" style="visibility: hidden"> <label class="col-md-4 control-label">Delivery Method</label> <div class="col-md-4 selectContainer"> <div class="input-group"> <span class="input-group-addon"><i class="glyphicon glyphicon-list"></i></span> <select id="mailtype" name="mailtype" class="form-control selectpicker" > <option value="Email" selected>Email</option> <!-- <option value="Hard Copy">Hard Copy</option> <option value="Hard Copy & Email">Hard Copy & Email</option>--> </select> </div> </div> </div> <!-- Success message --> <div class="alert alert-success" role="alert" id="success_message">Success <i class="glyphicon glyphicon-thumbs-up"></i> Thanks for placing your Order, we will contact you shortly.</div> <button id="submit" name="submit" type="submit" class="btn btn-success" >Submit Order <span class="glyphicon glyphicon-send"></span></button> <!--<input id="submit" type="submit" name="submit" value="Submit Order" />--> </fieldset> </form> I have a my validation rules set. $('#order').bootstrapValidator({ // To use feedback icons, ensure that you use Bootstrap v3.1.0 or later feedbackIcons: { valid: 'glyphicon glyphicon-ok', invalid: 'glyphicon glyphicon-remove', validating: 'glyphicon glyphicon-refresh' }, submitHandler: function(validator, form, submitButton) { $('#success_message').slideDown({ opacity: "show" }, "slow") // Do something ... var bv = form.data('bootstrapValidator'); // Use Ajax to submit form data $.post(form.attr('action'), form.serialize(), function(result) { $('#order').bootstrapValidator("resetForm",true); console.log(result); }, 'json'); }, excluded: [':disabled'], fields: { kits[COZ1][1][name]: { validators: { stringLength: { min: 2, }, notEmpty: { message: 'Please supply recipient name' } } }, requestorName: { validators: { stringLength: { min: 2, }, notEmpty: { message: 'Please supply your name' } } }, requestorEmail: { validators: { notEmpty: { message: 'Please supply your email address' }, emailAddress: { message: 'Please supply a valid email address' } } }, firm: { validators: { stringLength: { min: 3, }, notEmpty: { message: 'Please supply your Broker Dealer' } } }, /* address1: { validators: { stringLength: { min: 8, }, notEmpty: { message: 'Please supply recipient street address' } } }, address2: { validators: { stringLength: { min: 8, }, notEmpty: { message: 'Please supply your street address' } } }, city: { validators: { stringLength: { min: 4, }, notEmpty: { message: 'Please supply recipient city' } } }, state: { validators: { notEmpty: { message: 'Please select recipient state' } } }, zip: { validators: { notEmpty: { message: 'Please supply recipient zip code' }, zipCode: { country: 'US', message: 'Please supply a vaild zip code' } } }, phone: { validators: { notEmpty: { message: 'Please supply recipient phone number' }, phone: { country: 'US', message: 'Please supply a vaild phone number with area code' } } }, ship_email: { validators: { notEmpty: { message: 'Please supply recipient address' }, emailAddress: { message: 'Please supply a valid email address' } } }, */ } }).on('click', '.kitAdd',function() { var data = kitAdd($(this).attr("id").split("_")[1]); console.log(data); var prefix = data[0]; var suffix = data[1]; var type = data[2]; var template = $("#detail_"+type); var clone = template.clone(); clone.attr('id', "detail_"+type); // clone.insertBefore(template); var option = clone.find('input'); var name = prefix + "[name]"; option.attr('name', prefix + "[name]"); var obj = clone.find('[name="'+suffix+'[name]"]') $("form#order").bootstrapValidator("addField", obj); }); kitAdd function simply returns data needed for input name.
Kendo UI Editor Duplicating
I have a kendo grid with the following command below. When I first click on the command button, it works fine and there is 1 <input>, 1 <textarea> and 1 <input>. When I close the popup window and reopen it, the <textarea> is duplicated every time. command: [{ name: "Edit", title: "Alert Email", width: "180px", click: onDataBound75 }], Calling the following function: function onDataBound75(e) { e.preventDefault(); $("#txtAlert").kendoEditor({ resizable: { content: true, toolbar: true, encoded: false } }); var window = $("#emailAlert_popup").kendoWindow({ width: "600px", visible: false, modal: true, actions: [ "Maximize", "Close" ], }); var dataItem = this.dataItem($(e.currentTarget).closest("tr")); var viewModelAlert75 = kendo.observable({ Alert75EmailSubject: dataItem.Alert75EmailSubject, Alert75EmailBody: dataItem.Alert75EmailBody, Alert75FromAddress: dataItem.Alert75FromAddress, }); kendo.bind($("#emailAlert_popup"), viewModelAlert75); window.data("kendoWindow").center().open(); }; And the aspx file looks like this: <div id="emailAlert_popup" class="TT_PopupWindow"> <div class="SearchParam"> <label class="control-label" for="txtAlert75EmailSubject" style="width:200px">Email Subject</label> <input name="txtEmailSubject" id="txtAlert75EmailSubject" class="k-textbox" style="width:430px" data-bind="value: Alert75EmailSubject" /> </div> <div class="SearchParam"> <label class="control-label" for="txtAlert75EmailBody" style="width:200px">Email Body</label> <textarea id="txtAlert" rows="10" cols="30" style="height:440px" aria-label="editor" data-bind="value: Alert75EmailBody"></textarea> </div> <div class="SearchParam"> <label class="control-label" for="txtAlert75FromAddress" style="width:200px">From Address</label> <input name="txtFromAddress" id="txtAlert75FromAddress" class="k-textbox" style="width:430px" data-bind="value: Alert75FromAddress" /> </div> <div class="k-edit-buttons k-state-default"> <button type="button" id="btnAlert75EmailUpdate" data-role="button" class="k-button k-button-icontext k-primary k-grid-update" role="button" aria-disabled="false" tabindex="0" style="float:right"><span class="k-icon k-i-check"></span>Update</button> <button type="button" id="btnAlert75Cancel" data-role="button" class="k-button k-button-icontext k-grid-cancel" role="button" aria-disabled="false" tabindex="1" style="float:right"><span class="k-icon k-i-cancel"></span>Cancel</button> </div> </div>
I think that when you open the window for the second time or more, it's contents are already created so your are creating another kendoEditor over and existing one. Try this: if (!$("#txtAlert").data("kendoEditor")) { $("#txtAlert").kendoEditor({ resizable: { content: true, toolbar: true, encoded: false } }); } The above condition checks whenever the window will open, if the textarea is already an editor.
trumbowyg editor with vuejs
I am using the trumbowyg editor control in my vuejs spa. From the documentation I know that I can use the following code to set the contents of the editor. $('#editor').trumbowyg('html','<p>Your content here</p>'); $('#editor').trigger('tbwchange'); However, it is not working for me in my VueJs App. I have an object that has a description key defined. I can console.log the description , but when I try to assign it to the editor control as mentioned above, it fails . I can see no error in the console but the text just won't show up in the editor. Here is what I am going at the moment. <template> <div class="modal fade" data-backdrop="static" data-keyboard="false"> <div class="modal-dialog modal-lg"> <div class="modal-content"> <div class="modal-header"> <h4 class="modal-title"> <span v-if="anouncement">Edit Anouncement</span> <span v-else>New Anouncement</span> </h4> </div> <div class="modal-body"> <div class="form-group"> <input type="text" placeholder="enter anouncement summary here" class="form-control" v-model="anouncementObj.summary"> </div> <div class="form-group"> <input type="text" placeholder="enter location here" class="form-control" v-model="anouncementObj.location"> </div> <textarea class="note-view__body" id="anonDescription" v-model="description" placeholder="enter event description"></textarea> </div> <div class="modal-footer"> <button type="button" v-on:click="clear()" class="btn btn-link" data-dismiss="modal">Close</button> <button type="button" v-on:click="performSave()" class="btn btn-link">Save</button> </div> </div> </div> </div> </template> <script> export default { props : { anouncement : Object }, data() { return { anouncementObj :{} } }, mounted () { this.makeTextBoxReady(); this.anouncementObj = Object.assign({},this.anouncementObj, this.anouncement || {}); $('#anonDescription').trumbowyg('html',this.anouncement.description); $('#anonDescription').trigger('tbwchange'); console.log(this.anouncement.description); }, methods : { makeTextBoxReady: function() { $(document).ready(function() { if (!$('html').is('.ie9')) { if ($('.note-view__body')[0]) { $('.note-view__body').trumbowyg({ autogrow: true, btns: [ 'btnGrp-semantic', ['formatting'], 'btnGrp-justify', 'btnGrp-lists', ['removeformat'] ] }); } } }); }, performSave : function() { let description = $('#anonDescription').trumbowyg('html'); let formData = new FormData(); for (name in this.anouncementObj) { formData.append(name, this.anouncementObj[name]); } if( !this.anouncementObj.id) { this.anouncementObj.id = 0; } formData.append('description',description); this.$http.post('/admin/anouncement/createOrUpdate', formData).then(response => { // console.log(response); if(response.data.status==200) { alert(response.data.message); this.$emit('getAnouncements'); } }) }, clear: function() { this.anouncementObj= {}; } } } </script> Can you please let me know what I am doing wrong here? I have also tried the nexttick approach but even that is not working.
I got it working. I was not using the correct bootstrap modal id. Please see this related question for more information. This is the correct code. if(this.anouncementObj && this.anouncementObj.description && this.anouncementObj.id) { $('#'+this.anouncementObj.id+' #anonDescription').trumbowyg('html',this.anouncementObj.description); $('#'+this.anouncementObj.id+' #anonDescription').trigger('tbwchange'); }
Ui-grid column gets expand on hover
I am using ui-grid in angular which has 5 columns. on hover of grid options columns are getting expanded towards right side. Here is my file. HTML File <div class="full-panle-body"> <div class="row user-view-grid" ng-show="gridOptions.data.length > 0 && userLoaded"> <div ui-grid="gridOptions" ui-grid-auto-resize ui-grid-cellNav ui-grid-edit ui-grid-resize-columns ui-grid-pinning ng-style="getTableHeight()"></div> </div> <div class="row loading-spinner" ng-hide="userLoaded"> <div class="col-xs-3"></div> <div class="loading col-xs-6"> <span rel='spinner' class='data-spinner'></span> <div class="loading-text">{{::'label.loading.user.list' | translate}}</div> </div> <div class="col-xs-3"></div> </div> <div class="no-records" ng-show="!numberRecordsFound && userLoaded"> {{:: 'text.search.no.records' | translate }} </div> </div> <!-- html template for status --> <script type="text/ng-template" id="statusCell-template.html"> <div ng-click="grid.appScope.onUserDetails(row.entity)" class="inner-data-cell-center"> <div style="text-align:center;"> <i class="fa fa-envelope-o" aria-hidden="true" style="color:grey;" ng-show="'added' == row.entity.registrationStatus.toLowerCase()"></i> <i class="fa fa-envelope-o" aria-hidden="true" style="color:blue;" ng-show="'notified' == row.entity.registrationStatus.toLowerCase()"></i> <i class="fa fa-check" aria-hidden="true" style="color:green;" ng-show="'complete' == row.entity.registrationStatus.toLowerCase()"></i> </div> <div style="text-align:center;" class="smaller-grey">{{row.entity.registrationStatus}}</div> </div> </script> <script type="text/ng-template" id="name-template.html"> <div class="ui-grid-cell-contents" ng-click="grid.appScope.onUserDetails(row.entity)"> <div class="name-style">{{row.entity.lastName}}, {{row.entity.firstName}}</div> <div class="email-style">{{row.entity.email}}</div> </div> </script> <!-- html template for organization --> <script type="text/ng-template" id="organization-template.html"> <div class="single-elm-style" ng-click="grid.appScope.onUserDetails(row.entity)"> <span class="dummy">{{row.entity.organization}}</span> </div> </script> <!-- html template for username --> <script type="text/ng-template" id="username-template.html"> <div class="single-elm-style" ng-click="grid.appScope.onUserDetails(row.entity)"> <span>{{row.entity.userName}}</span> </div> </script> <!-- html template for Account Status --> <script type="text/ng-template" id="accountstatus-template.html"> <div class="single-elm-style" ng-click="grid.appScope.onUserDetails(row.entity)"> <span ng-show="row.entity.isActive">Enabled</span> <span ng-show="!row.entity.isActive">Disabled</span> </div> </script> CSS File .ui-grid-row:hover{ border-left: solid 6px #hoverBlue; } JS File $scope.gridOptions = { rowHeight: 60, multiSelect: false, enableColumnMenus: false, enableEdit: false, enableSoring: true, columnDefs: [ { name: 'registrationStatus', width: "15%", displayName: 'Status', headerCellClass: 'grid-header-center', cellClass: 'grid-data-cell', cellTemplate: 'statusCell-template.html' }, { name: 'lastName', width: "30%", displayName: 'Name', headerCellClass: 'grid-header-left', cellTemplate: 'name-template.html' }, { name: 'organization', width: "15%", displayName: 'Organization', headerCellClass: 'grid-header-left', cellTemplate: 'organization-template.html' }, { name: 'userName', width: "20%", displayName: 'Username', headerCellClass: 'grid-header-left', cellTemplate: 'username-template.html' }, { name: 'isActive', width: "20%", displayName: 'Account Status', headerCellClass: 'grid-header-left', cellTemplate: 'accountstatus-template.html' } ] }; Hi.I am using ui-grid in angular which has 5 columns. on hover of grid options columns are getting expanded towards right side.