vendredi 1 avril 2016

Aspxgridview command column loses value when page changes

I am using VS 2013 VB. I have a aspxgridview that uses objectdatasource. One of the columns is a command column used as a checkbox named "Select". When the user selects a checkbox and then goes to another page and then back to the page where they made a selected checkbox that check mark is gone. It is not retaining the selection. This is a grid of inventory items. I want to make multiple selections and then click on a button. On the button click I want to open a separate page with the items that were checked. This is to create a work order.

Any ideas of how to accomplish this? I am using VB not C#. Thanks in advance! Below is the grid:

 <dx:ASPxGridView ID="gvInventory" runat="server" AutoGenerateColumns="False" DataSourceID="InventoryDataSource" EnableTheming="True" Theme="Office2003Olive" EnableRowsCache="False" KeyFieldName="ID_Number">
     <Columns>
          <dx:GridViewDataTextColumn FieldName="ID_Number" Visible="False" VisibleIndex="7">
          </dx:GridViewDataTextColumn>
          <dx:GridViewDataTextColumn Caption="Item" FieldName="Item_Number" VisibleIndex="2" Width="25px">
          </dx:GridViewDataTextColumn>
          <dx:GridViewDataTextColumn Caption="Description" FieldName="Item_Description" VisibleIndex="3">
          </dx:GridViewDataTextColumn>
          <dx:GridViewDataTextColumn Caption="Cost" FieldName="Current_Cost" VisibleIndex="6" Width="15px">
              <PropertiesTextEdit DisplayFormatString="{0:c}">
              </PropertiesTextEdit>
          </dx:GridViewDataTextColumn>
          <dx:GridViewDataTextColumn Caption="WH" FieldName="Warehouse_Location" VisibleIndex="4" Width="15px">
          </dx:GridViewDataTextColumn>              
          <dx:GridViewDataDateColumn Caption="Date Rcv'd" FieldName="Last_Receipt_Date" VisibleIndex="1" Width="25px">
          </dx:GridViewDataDateColumn>              
          <dx:GridViewDataTextColumn Caption="QTY On Hand" FieldName="Quantity_On_Hand" VisibleIndex="5" Width="20px">                 
              <HeaderStyle Wrap="True" />
          </dx:GridViewDataTextColumn>
          <dx:GridViewDataTextColumn FieldName="Current_Month_Issue_Quantity" Visible="False" VisibleIndex="17">
          </dx:GridViewDataTextColumn>          

          <dx:GridViewCommandColumn Caption="Select" ShowInCustomizationForm="True" ShowSelectCheckbox="True" VisibleIndex="0">
          </dx:GridViewCommandColumn>
      </Columns>
      <Settings ShowFilterRow="True" ShowGroupPanel="True" />
      <SettingsSearchPanel Visible="true" />
      <SettingsDataSecurity AllowDelete="False" AllowEdit="False" AllowInsert="False" />
  </dx:ASPxGridView>




angular grid selected checkbox scroll issue

I have a column with a celltemplate of checkbox. It can be selected/unselected, which works fine as correct events are fired everytime. However, when I select multiple checkboxes on the grid and start scrolling up and down, the checkboxes seem to be scrolling as well. That means that they are not fixed to the rows they are checked against, and get lined up against a wrong row.

This issue has already been reported here a couple of years ago. But the solution posted, does not solve the problem.

Here is a plunker link to demonstrate the issue. Anyone had any similar issue or a workaround to this?




how to filter using multiple check box value from mysql database using jquey and php

I have a dynamic page ie. all-offer.php?category=beauty-spa according to category i have some stores to display and respective all location with checkbox according to category. html part according to category

<?php 
                    foreach($qry_1 as $v){
                    ?>
                        <a class="col-md-4" href="#">
                            <div class="product-thumb">
                                <header class="product-header">
                                    <img src="<?php echo str_replace('../','',$v['offer_image']) ?>" alt="Image Alternative text" title="Ana 29" />
                                </header>
                                <div class="product-inner">
                                    <h5 class="product-title"><?php $v['title'] ?></h5>
                                    <p class="product-desciption"><?php $v['description'] ?></p>

                                    <p class="product-location"><i class="fa fa-map-marker"></i> <?php echo $v['location'] ?></p>
                                </div>
                            </div>
                        </a>
                        <?php
                    }
                        ?>

from above code i can able to fetch all outlets and their locations i want to filter outlets if i checked the location checkbox. i get the checkbox value using jquey and post it to filter.php

$('input#locality').change(function () {
  var locality = [];
  $(':checkbox:checked').each(function (i) {
    locality.push($(this).val());
});
$.ajax({
            type:'POST',
            url:"php/filter.php",
            data:{name: locality},
            dataType:"json",
            success: function(data){
                $.each(data, function(index, element) {

                    $('.response').append('')

                });
                }})
});

and i received the data in filter.php part is

$qry_1=array();

    $checkbox1=$_POST['name'];  
$chk="";   
foreach($checkbox1 as $chk1)  
   {  
      $chk .= $chk1;  
   }
$sql_1="SELECT  p.id,p.outlet_id,p.offer_title,p.original_price,p.discount,p.discount_price,p.offer_image,p.offer_details,o.outlet_id,o.outlet_title,o.outlet_locality,o.segment_type FROM products as p,outlets as o WHERE p.outlet_id=o.outlet_id AND o.outlet_locality='$chk'"; 
$qry_1=sel_qry($sql_1);
foreach($qry_1 as $v)
{
    $filterloc[]=array('title'=>$v['outlet_title'],'cat_id'=>$v['outlet_id']);
}
echo json_encode($filterloc);  

i m getting error when i check multiple checkbox it shows $filterloc is not defined my question is how to get data as json in jquery and refresh my content according to location checked




Generated checkboxes : how to make working my code with my EDIT part in my controller and make a search keeping the checked value

i have this code which generate checkboxes from my table HairTags, This code works already with my CEATION in my controller, but i woul love to use it in my EDIT, adn i do not knwo how to change my EDIT code in order to use checkboxes in my edit form. Model

namespace HairCollection3.Models
{
    public class Creation
    {
        public string UserId { get; set; }
        [Key]
        public int CreationId { get; set; }
        public string CreationLanguage { get; set; }

        [Required(ErrorMessageResourceName = "Required", ErrorMessageResourceType = typeof(ViewRes.ValidationStrings))]
        [Display(Name = "Sex", ResourceType = typeof(ViewRes.Names))]
        public string CreationSex { get; set; }

        [Required(ErrorMessageResourceName = "Required", ErrorMessageResourceType = typeof(ViewRes.ValidationStrings))]
        [Display(Name = "CreationTitle", ResourceType = typeof(ViewRes.NamesCreation))]
        [StringLength(2000)]
        [AllowHtml]
        public string CreationTitle { get; set; }

        public bool CreationVisible { get; set; }
        public bool CreationDelete { get; set; }
        public DateTime CreationDate { get; set; }
        public string CreationIpAdress { get; set; }

        public string CreationPhotoBis { get; set; }
        public string CreationPhoto750 { get; set; }
        public string CreationPhotoReal { get; set; }

        public string Creationtag { get; set; }

        public virtual ICollection<CreationLike> CreationLikes { get; set; }        

    }

    public class CreationLike
    {
        public int CreationId { get; set; }
        public string UserId { get; set; }
        public virtual ApplicationUser User { get; set; }
        [Key]
        public int CreationLikeId { get; set; }
        public DateTime CreationLikeDate { get; set; }
        public string CreationLikeIpAdress { get; set; }

        public virtual Creation ParentCreation { get; set; }

    }

    public class HairTag
    {
        [Key]
        public int HairTagId { get; set; }

        [Required]
        public string HairTagTitle { get; set; }
        [Required]
        public string HairTagTitleEN { get; set; }
        [Required]
        public string HairTagTitleIT { get; set; }
        [Required]
        public string HairTagTitleSP { get; set; }

        [Required]
        public string HairTagType { get; set; }

        [Required]
        public int HairTagOrder { get; set; }   
    }





    //CHECKBOXES
    public class HairTagModel
    {
        //[Key]
        public int Value { get; set; }
        public string Text { get; set; }
        public bool IsChecked { get; set; }
    }


    public class CreationHairTagsModel
    {
        public CreationHairTagsModel()
        {
            Creation = new Creation();
        }
        public Creation Creation { get; set; }

        public List<HairTagModel> CreationHairTags { get; set; }

    }


}

Controller : CREATE CODE

GET: /Creation/CreationUpload [Authorize] public ActionResult CreationUpload() { var model = new CreationHairTagsModel();

        model.CreationHairTags = db.HairTags.Select(x => new HairTagModel { Text = x.HairTagTitle, Value = x.HairTagId }).ToList();

        return View(model);

    }

    // POST: /Creation/CreationUpload[HttpPost]
    [Authorize]
    [ValidateAntiForgeryToken]
    public ActionResult CreationUpload(CreationHairTagsModel creationbind, IEnumerable<HttpPostedFileBase> files)
    {
        if (ModelState.IsValid)
        {  

EDIT CODE

// GET: /Creation/CreationEdit/5
        [Authorize]
        public ActionResult CreationEdit(int? id)
        {
            Creation creation = db.Creations.Find(id);

            return View(creation);
        }


        // POST: /Creation/CreationEdit/5
 [HttpPost]
        [ValidateAntiForgeryToken]
        [Authorize]
        public ActionResult CreationEdit([Bind(Include = "CreationId,CreationSex,CreationTitle")] Creation creation)
        {
            if (ModelState.IsValid)
            {

And also i would love to improve my search form with this code in order to have the checkboxes in my form and keep them checked when a user search for something and chechk some of them... Search code :

        // Index/
        [AllowAnonymous]
        public ActionResult Index(string sortOrder, string currentFilter, string searchString, string currentFilterSex, string searchStringSex, int? page)
        {
            //SORTING 
            ViewBag.CurrentSort = sortOrder;
            ViewBag.NameSortParm = String.IsNullOrEmpty(sortOrder) ? "name_desc" : "";
            ViewBag.DateSortParm = sortOrder == "Date" ? "date_desc" : "Date";

            //I  think you can actually drop the Likes include as it will be included with the Likes.Select include, so maybe try this (although if it doesn't work, use the first example which should):
            var creations = db.Creations.Include(m => m.CreationLikes.Select(l => l.User)) as IQueryable<Creation>;

            //SEARCH
             //Pagination
            if (searchString != null)
            {
                page = 1;
            }
            else
            {
                searchString = currentFilter;
            }
            ViewBag.CurrentFilter = searchString;
            if (!String.IsNullOrEmpty(searchString))
            {
                creations = creations.Where(r => r.CreationTitle.ToUpper().Contains(searchString.ToUpper()));
            }

            //Sex
            if (searchStringSex == null)
            {
                searchStringSex = currentFilterSex;
            }
            ViewBag.currentFilterSex = searchStringSex;
            if (!String.IsNullOrEmpty(searchStringSex))
            {
                creations = creations.Where(r => r.CreationSex.ToUpper().Contains(searchStringSex.ToUpper()));
            }

            //SEX



            //Language
            creations = creations.Where(r => r.CreationLanguage.ToUpper().Equals(ViewRes.Shared.Langue.ToUpper()));

            //Not hidden by admin and Not deleted by user
            creations = creations.Where(r => r.CreationVisible.Equals(true));
            creations = creations.Where(r => r.CreationDelete.Equals(false));

            //SORTING 
creations = creations.OrderByDescending(r => r.CreationDate);


            //FIRST 100 SALON
            creations = creations.Take(100);

            //Pagination
            int pageSize = 80;
            int pageNumber = (page ?? 1);
            return View(creations.ToPagedList(pageNumber, pageSize));


        }

please help!!




Warning messages for two groups of checkboxes

Hi guys I have jQuery code to validate if checkboxes are checked, and if they are not warning messages are displayed. All works fine. Here is a code:

$(document).ready(function() {
    var checkboxes = $('.require-one');
    var checkbox_names = $.map(checkboxes, function(e, i) {
        return $(e).attr("name")
    }).join(" ");

    $("#itemForm").validate({
        groups: {
            checks: checkbox_names
        },
        rules: {
            resp01: 'required',
        },
        messages: {
            resp01: {
                required: 'You must agree before submitting!'
            },
        },
        errorPlacement: function(error, element) {
            $('#form_error1').append(error);
        },
        errorPlacement: function(error, element) {
            $('#form_error').append(error);
        },
        submitHandler: function(form) {
            alert('Form Submited');
            return false;
        }

    });
});

$.validator.addMethod('require-one', function(value) {
    if ($('#resp01').is(':checked')) {
        return $('.require-one:checked').size() > 0;
    } else {
        return true;
    }
}, 'Please select one of the options.');

There are two messages for two different groups of checkboxes. At the moment both messages are displayed under last checkbox. What I want is to display messages under appropriate section. Here is JSFiddle. Any help appreciated.




filtet data by checkbox using jquery ajax mysql and php

i have a group of dynamic checkbox of location

    <?php
        foreach($qry_2 as $v2){

    ?>
    <li class="checkbox">
        <label>
     <input type="checkbox" class="i-check" id="locality" name="locality[]" value="<?php echo $v2['outlet_locality'] ?>"><?php echo $v2['outlet_locality'] ?> <small class="location"><?php echo '('.$v2['outletCount'].')' ?></small>
        </label>
    </li>
<?php
}
?>

and i got aprox 10 input checkbox values i want to filter the content according to the checkbox(multiple select) using jquery and send data to filter.php to retrive as json data

$('input#locality').change(function(){

 var locality = [];
    $(':checkbox:checked').each(function(i){
      locality[i] = $(this).val();

    alert(locality[i])



   $.post("filter.php", {name: locality[i]}, function(data){
       alert(data);
});
   });
});

when i checked the checkbox i got indivisual value not an array,so how can i get the array value of multiple checkbox checked to send to the filter.php




When i send my form, my checkboxes values results always NULL

i have a form where i populate some checkboxes from the table HairTags ,

all works fine, i show my checkboxes in my form, but when i choose some of them and i try to send, all the value results NULL and i do not save them ids inside my filed Creationtag

in my model

//CHECKBOXES
public class HairTagModel
{
    //[Key]
    public int Value { get; set; }
    public string Text { get; set; }
    public bool IsChecked { get; set; }
}



public class CreationHairTagsModel
{
    //public Creation Creation { get; set; }
    //public List<HairTagModel> CreationHairTags { get; set; }

    public CreationHairTagsModel()
    {
        Creation = new Creation();
    }
    public Creation Creation { get; set; }

    private ApplicationDbContext creationdb = new ApplicationDbContext();

    public List<HairTagModel> CreationHairTags
    {
        get
        { 
            var HairTagList = creationdb.HairTags.ToList();

            List<HairTagModel> obj = new List<HairTagModel>();

            foreach (var tags in HairTagList)
            {
                obj.Add(new HairTagModel
                {
                    Text = tags.HairTagTitle,
                    Value = tags.HairTagId,
                    IsChecked = false
                });
            }

            return obj;
        }
    }
}

in my page

<div class="col-md-12">
            @for (int i = 0; i < Model.CreationHairTags.Count; i++)
            {
                @Html.CheckBoxFor(m => Model.CreationHairTags[i].IsChecked)
                @Model.CreationHairTags[i].Text
                @Html.HiddenFor(m => Model.CreationHairTags[i].Value)
                @Html.HiddenFor(m => Model.CreationHairTags[i].Text)<br />
            }
        </div>

in my controller

[HttpPost]
        [Authorize]
        [ValidateAntiForgeryToken]
        public ActionResult CreationUpload(CreationHairTagsModel creationbind, IEnumerable<HttpPostedFileBase> files)
        {
            if (ModelState.IsValid)
            {   
            ...CODE HIDDEN...

                               //Tags
                                StringBuilder sb = new StringBuilder();
                                foreach (var item in creationbind.CreationHairTags)
                                {
                                    if (item.IsChecked)
                                    {                                        
                                        sb.Append(item.Value + ",");
                                    }
                                }
                                creationbind.Creation.Creationtag = sb.ToString();

What is wrong in my code please help and explain ?