some items were checked when the page loaded

Hi
Is it possible that some items were checked when the page loaded? 

6 Replies 1 reply marked as answer

YE yeadam January 10, 2021 07:57 PM UTC

It has been a while since I asked for help with this
Is this not possible?


SN Sevvandhi Nagulan Syncfusion Team January 11, 2021 06:28 AM UTC

Hi Yeadam, 


Greetings from Syncfusion support. 


We checked your query. You can select the some items using the value property. Please refer the below code, 

[Index.cshtml] 

<ejs-multiselect id="checkList" dataSource="@ViewBag.data" value="@ViewBag.value"  mode="CheckBox" placeholder="Select countries" 
                 showSelectAll="true" showDropDownIcon="true" 
                 filterBarPlaceholder="Search countries" popupHeight="350px"> 
    <e-multiselect-fields text="Name" value="Code"></e-multiselect-fields> 
</ejs-multiselect> 

[HomeController.cs] 


public IActionResult Index() 
        { 
            ViewBag.value = new string[] { "AU", "BM" }; 
            ViewBag.data = new Countries().CountriesList(); 
            return View(); 
        } 

Please find the sample below, 



Please check the above sample and get back to us if you need further assistance. 

Regards, 
Sevvandhi N 



YE yeadam January 11, 2021 09:49 PM UTC

Thanks for your reply
This method works fine but does not work when  "ejs-for"  are used in code

That is, if we change your example code below, it will not work

<ejs-multiselect id="checkList" ejs-for="@Model.List_rec_id"   dataSource="@ViewBag.data" value="@ViewBag.value"  mode="CheckBox" placeholder="Select countries"   showSelectAll="true" showDropDownIcon="true" 
                 filterBarPlaceholder="Search countries" popupHeight="350px"> 
    <e-multiselect-fields text="Name" value="Code">e-multiselect-fields> 
ejs-multiselect> 


to solve this problem
I think we need to use JavaScript to do this. it's true?
If yes, please help me


SN Sevvandhi Nagulan Syncfusion Team January 12, 2021 09:19 AM UTC

Hi Yeadam, 


We checked your query. We would like to inform you that, ejs-for property is equivalent to the value property. So ejs-for property will work as value property. When you use the that property, then no need to preselect the value using value property. You can select some items by using the ejs-for property. Hence we suggest you to remove the value property and provide that code in the ejs-for property. Refer the below code, 


[Index.cshtml] 
 
 
<ejs-multiselect id="checkList" dataSource="@ViewBag.data" ejs-for="@Model.value" mode="CheckBox" placeholder="Select countries" 
                 showSelectAll="true" showDropDownIcon="true" 
                 filterBarPlaceholder="Search countries" popupHeight="350px"> 
    <e-multiselect-fields text="Name" value="Code"></e-multiselect-fields> 
</ejs-multiselect> 
 
 
[HomeController.cs] 
 
public IActionResult Index() 
        { 
            Countries model = new Countries(); 
            model.value = new string[] { "AU", "BM" }; 
            ViewBag.data = new Countries().CountriesList(); 
            return View(model); 
        } 
 
        public class Countries 
        { 
            public string Name { get; set; } 
            public string Code { get; set; } 
 
            public string[] value { get; set; } 
        } 
 
 

Please find the sample below, 




Please check the above sample and get back to us if you need further assistance. 


Regards, 
Sevvandhi N 


Marked as answer

YE yeadam January 13, 2021 09:56 PM UTC

Thank you




VS Vignesh Srinivasan Syncfusion Team January 14, 2021 06:08 AM UTC

Hi yeadam, 
 
Thanks for the update. 
Please get back to us if you need further assistance. 
  
Regards, 
Vignesh Srinivasan. 
 


Loader.
Up arrow icon